Skip to content

BindStyledParameterWithOptions loses error type informations #70

Open
@constantoine

Description

@constantoine

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions