v0.0.248 exerr in wmo package
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 55s

This commit is contained in:
2023-08-21 15:08:35 +02:00
parent 9b752a911c
commit ae43cbb623
12 changed files with 128 additions and 52 deletions

View File

@@ -2,12 +2,17 @@ package wmo
import (
"context"
"gogs.mikescher.com/BlackForestBytes/goext/exerr"
)
func (c *Coll[TData]) decodeSingle(ctx context.Context, dec Decodable) (TData, error) {
if c.customDecoder != nil {
return (*c.customDecoder)(ctx, dec)
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 res, nil
} else {
@@ -15,7 +20,7 @@ func (c *Coll[TData]) decodeSingle(ctx context.Context, dec Decodable) (TData, e
err := dec.Decode(&res)
if err != nil {
return *new(TData), err
return *new(TData), exerr.Wrap(err, "failed to decode single entity").Type("target-type", res).Build()
}
return res, nil
@@ -31,7 +36,7 @@ func (c *Coll[TData]) decodeAll(ctx context.Context, cursor Cursorable) ([]TData
for cursor.Next(ctx) {
entry, err := (*c.customDecoder)(ctx, cursor)
if err != nil {
return nil, err
return nil, exerr.Wrap(err, "failed to decode entity with custom-decoder").Type("decoder", *c.customDecoder).Build()
}
res = append(res, entry)
}
@@ -44,7 +49,7 @@ func (c *Coll[TData]) decodeAll(ctx context.Context, cursor Cursorable) ([]TData
err := cursor.All(ctx, &res)
if err != nil {
return nil, err
return nil, exerr.Wrap(err, "failed to batch-decode entity").Type("target-type", res).Build()
}
return res, nil