Skip to content

Commit bca20a1

Browse files
error ignore
1 parent 8fb041d commit bca20a1

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

aggregator/aggregator.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ func (a *Aggregator[T]) Aggregate(ctx context.Context, opts ...options.Lister[op
8787
if err != nil {
8888
return nil, err
8989
}
90-
defer cursor.Close(ctx)
90+
defer func(cursor *mongo.Cursor, ctx context.Context) {
91+
_ = cursor.Close(ctx)
92+
}(cursor, ctx)
9193

9294
result := make([]*T, 0)
9395
err = cursor.All(ctx, &result)
@@ -122,7 +124,9 @@ func (a *Aggregator[T]) AggregateWithParse(ctx context.Context, result any, opts
122124
if err != nil {
123125
return err
124126
}
125-
defer cursor.Close(ctx)
127+
defer func(cursor *mongo.Cursor, ctx context.Context) {
128+
_ = cursor.Close(ctx)
129+
}(cursor, ctx)
126130
err = cursor.All(ctx, result)
127131
if err != nil {
128132
return err

finder/finder.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ func (f *Finder[T]) Find(ctx context.Context, opts ...options.Lister[options.Fin
207207
if err != nil {
208208
return nil, err
209209
}
210-
defer cursor.Close(ctx)
210+
defer func(cursor *mongo.Cursor, ctx context.Context) {
211+
_ = cursor.Close(ctx)
212+
}(cursor, ctx)
211213
err = cursor.All(ctx, &t)
212214
if err != nil {
213215
return nil, err

0 commit comments

Comments
 (0)