1

Since IMongoCollection<T>.InsertOneAsync(...) returns no value (except the awaitable Task), and its documentation says nothing about exceptions, how can I be sure that the new record was added and no error has happened?

IMongoCollection<RecordType> batch = recordsBatchFactory.Create();
RecordType newRecord = makeNewRecord();
await batch.InsertOneAsync(newRecord);
// is newRecord guaranteed to be in the DB at this point?
Tar
  • 8,529
  • 9
  • 56
  • 127

1 Answers1

2

If an exception happens within the task it should cause the task to return faulted, see Task<>.IsFaulted.

However the exception should bubble up and be raised as an AggregateException.

Lloyd
  • 29,197
  • 4
  • 84
  • 98
  • I'm just confused, why doesn't the documentation say anything about exceptions... – Tar May 24 '16 at 11:44