@@ -248,7 +248,7 @@ func (coll *Collection) BulkWrite(ctx context.Context, models []WriteModel,
248248
249249 err = op .execute (ctx )
250250
251- return & op .result , replaceErrors (err )
251+ return & op .result , wrapErrors (err )
252252}
253253
254254func (coll * Collection ) insert (
@@ -1049,15 +1049,15 @@ func aggregate(a aggregateParams, opts ...options.Lister[options.AggregateOption
10491049 if errors .As (err , & wce ) && wce .WriteConcernError != nil {
10501050 return nil , * convertDriverWriteConcernError (wce .WriteConcernError )
10511051 }
1052- return nil , replaceErrors (err )
1052+ return nil , wrapErrors (err )
10531053 }
10541054
10551055 bc , err := op .Result (cursorOpts )
10561056 if err != nil {
1057- return nil , replaceErrors (err )
1057+ return nil , wrapErrors (err )
10581058 }
10591059 cursor , err := newCursorWithSession (bc , a .client .bsonOpts , a .registry , sess )
1060- return cursor , replaceErrors (err )
1060+ return cursor , wrapErrors (err )
10611061}
10621062
10631063// CountDocuments returns the number of documents in the collection. For a fast count of the documents in the
@@ -1132,7 +1132,7 @@ func (coll *Collection) CountDocuments(ctx context.Context, filter interface{},
11321132
11331133 err = op .Execute (ctx )
11341134 if err != nil {
1135- return 0 , replaceErrors (err )
1135+ return 0 , wrapErrors (err )
11361136 }
11371137
11381138 batch := op .ResultCursorResponse ().FirstBatch
@@ -1213,7 +1213,7 @@ func (coll *Collection) EstimatedDocumentCount(
12131213 op .Retry (retry )
12141214
12151215 err = op .Execute (ctx )
1216- return op .Result ().N , replaceErrors (err )
1216+ return op .Result ().N , wrapErrors (err )
12171217}
12181218
12191219// Distinct executes a distinct command to find the unique values for a specified field in the collection.
@@ -1302,7 +1302,7 @@ func (coll *Collection) Distinct(
13021302
13031303 err = op .Execute (ctx )
13041304 if err != nil {
1305- return & DistinctResult {err : replaceErrors (err )}
1305+ return & DistinctResult {err : wrapErrors (err )}
13061306 }
13071307
13081308 arr , ok := op .Result ().Values .ArrayOK ()
@@ -1504,12 +1504,12 @@ func (coll *Collection) find(
15041504 op = op .Retry (retry )
15051505
15061506 if err = op .Execute (ctx ); err != nil {
1507- return nil , replaceErrors (err )
1507+ return nil , wrapErrors (err )
15081508 }
15091509
15101510 bc , err := op .Result (cursorOpts )
15111511 if err != nil {
1512- return nil , replaceErrors (err )
1512+ return nil , wrapErrors (err )
15131513 }
15141514 return newCursorWithSession (bc , coll .bsonOpts , coll .registry , sess )
15151515}
@@ -1560,7 +1560,7 @@ func (coll *Collection) FindOne(ctx context.Context, filter interface{},
15601560 cur : cursor ,
15611561 bsonOpts : coll .bsonOpts ,
15621562 reg : coll .registry ,
1563- err : replaceErrors (err ),
1563+ err : wrapErrors (err ),
15641564 }
15651565}
15661566
@@ -2044,7 +2044,7 @@ func (coll *Collection) drop(ctx context.Context) error {
20442044 // ignore namespace not found errors
20452045 var driverErr driver.Error
20462046 if ! errors .As (err , & driverErr ) || ! driverErr .NamespaceNotFound () {
2047- return replaceErrors (err )
2047+ return wrapErrors (err )
20482048 }
20492049 return nil
20502050}
0 commit comments