如果 IMongoCollection<T>.InsertOneAsync(...) returns 没有值也不抛出任何异常(根据文档),如何捕获错误?

How to catch errors if IMongoCollection<T>.InsertOneAsync(...) returns no value nor throws any exception (according to documentation)?

因为 IMongoCollection<T>.InsertOneAsync(...) returns 没有值(awaitable Task 除外),并且 its documentation 没有提到异常,我怎么能确定添加了新记录并且没有发生错误?

IMongoCollection<RecordType> batch = recordsBatchFactory.Create();
RecordType newRecord = makeNewRecord();
await batch.InsertOneAsync(newRecord);
// is newRecord guaranteed to be in the DB at this point?

如果任务中发生异常,它应该会导致任务 return 出错,请参阅 Task<>.IsFaulted

然而,异常应该冒泡并作为 AggregateException.

引发