Replies: 1 comment 1 reply
-
@barata0 it depends on what you want to log exactly. I would suggest either a middleware or a transformer:
Another possibility is to use your own register function, something like: func MyRegister[I, O any](api huma.API, op huma.Operation, handler func(context.Context, *I) (*O, error)) {
huma.Register(api, op, func(ctx context.Context, input *I) (*O, error) {
result, err := handler(ctx, input)
if err != nil {
// Do something here!
}
return result, err
})
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Let´s suppose I want to log every error returned by the handlers
I believe the best way to do this is using a middleware and if there is an error log it.
Best I could think about is this:
But ctx.Context.Err is nil.
Beta Was this translation helpful? Give feedback.
All reactions