Description
Context:
I have a custom type, implementing encoding.TextUnmarshaler
, that returns a domain error upon failed unmarshaling. This error is somehow not propagated to my ErrorHandler
Expected behavior:
Upon my custom path parameter type being bound in BindStyledParameterWithOptions, the parameter is recognized as an encoding.TextUnmarshaler
, and when the domain error it returns can be errors.As
'd inside the ErrorHandler
setup as
openapi.RegisterHandlersWithOptions(srv.router, srv, openapi.GinServerOptions{
ErrorHandler: inboundErrHandler,
})
Actual behavior:
In BindStyledParameterWithOptions
, errors is wrapped as fmt.Errorf("error unmarshaling '%s' text as %T: %s", value, dest, err)
, which loses all information about the error, making error handling in the Handler more difficult
Proposed fix:
BindStyledParameterWithOptions should return errors wrapped as %w
instead of %s
/%v
(there seems to be inconsistencies as to which is used).