v0.0.321 Add .NoLog() to lowest-level query exerr.Wrap in wmo (otherwise we get error logs on stdout even if the callign method allows mongo.ErrNoDocuments)
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m4s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m4s
This commit is contained in:
@@ -14,12 +14,12 @@ func (c *Coll[TData]) decodeSingle(ctx context.Context, dec Decodable) (TData, e
|
||||
if c.customDecoder != nil {
|
||||
res, err = (*c.customDecoder)(ctx, dec)
|
||||
if err != nil {
|
||||
return *new(TData), exerr.Wrap(err, "failed to decode single entity with custom-decoder").Type("decoder", *c.customDecoder).Build()
|
||||
return *new(TData), exerr.Wrap(err, "failed to decode single entity with custom-decoder").Type("decoder", *c.customDecoder).NoLog().Build()
|
||||
}
|
||||
} else {
|
||||
err = dec.Decode(&res)
|
||||
if err != nil {
|
||||
return *new(TData), exerr.Wrap(err, "failed to decode single entity").Type("target-type", res).Build()
|
||||
return *new(TData), exerr.Wrap(err, "failed to decode single entity").Type("target-type", res).NoLog().Build()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,12 +75,12 @@ func (c *Coll[TData]) decodeSingleOrRequery(ctx context.Context, dec Decodable)
|
||||
var res genDoc
|
||||
err := dec.Decode(&res)
|
||||
if err != nil {
|
||||
return *new(TData), exerr.Wrap(err, "failed to ID-decode entity").Build()
|
||||
return *new(TData), exerr.Wrap(err, "failed to ID-decode entity").NoLog().Build()
|
||||
}
|
||||
|
||||
v, err := c.findOneInternal(ctx, bson.M{"_id": res.ID}, false)
|
||||
if err != nil {
|
||||
return *new(TData), exerr.Wrap(err, "failed to re-query entity").Any("_id", res.ID).Build()
|
||||
return *new(TData), exerr.Wrap(err, "failed to re-query entity").Any("_id", res.ID).NoLog().Build()
|
||||
}
|
||||
|
||||
return *v, nil
|
||||
|
@@ -58,7 +58,7 @@ func (c *Coll[TData]) findOneInternal(ctx context.Context, filter bson.M, allowN
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, exerr.Wrap(err, "mongo-query[find-one] failed").Any("filter", filter).Str("collection", c.Name()).Build()
|
||||
return nil, exerr.Wrap(err, "mongo-query[find-one] failed").Any("filter", filter).Str("collection", c.Name()).NoLog().Build()
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
@@ -75,19 +75,19 @@ func (c *Coll[TData]) findOneInternal(ctx context.Context, filter bson.M, allowN
|
||||
|
||||
cursor, err := c.coll.Aggregate(ctx, pipeline)
|
||||
if err != nil {
|
||||
return nil, exerr.Wrap(err, "mongo-aggregation [find-one] failed").Any("pipeline", pipeline).Str("collection", c.Name()).Build()
|
||||
return nil, exerr.Wrap(err, "mongo-aggregation [find-one] failed").Any("pipeline", pipeline).Str("collection", c.Name()).NoLog().Build()
|
||||
}
|
||||
|
||||
if cursor.Next(ctx) {
|
||||
v, err := c.decodeSingle(ctx, cursor)
|
||||
if err != nil {
|
||||
return nil, exerr.Wrap(err, "mongo-aggregation [find-one] failed to decode results").Any("pipeline", pipeline).Str("collection", c.Name()).Build()
|
||||
return nil, exerr.Wrap(err, "mongo-aggregation [find-one] failed to decode results").Any("pipeline", pipeline).Str("collection", c.Name()).NoLog().Build()
|
||||
}
|
||||
return &v, nil
|
||||
} else if allowNull {
|
||||
return nil, nil
|
||||
} else {
|
||||
return nil, exerr.Wrap(mongo.ErrNoDocuments, "mongo-aggregation [find-one] returned no documents").Any("pipeline", pipeline).Str("collection", c.Name()).Build()
|
||||
return nil, exerr.Wrap(mongo.ErrNoDocuments, "mongo-aggregation [find-one] returned no documents").Any("pipeline", pipeline).Str("collection", c.Name()).NoLog().Build()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user