Skip to content

unwrap for internal errors #422

@bionoren

Description

@bionoren

Implement https://pkg.go.dev/errors#Unwrap on internal errors like openapi3filter.RequestError and openap3.SchemaError so we can use errors.Is/errors.As to inspect them

My specific use case is that I have a *openapi3filter.RequestError where the Err property is a *openapi3.SchemaError, and I want to call JSONPointer() on it to get the path where the error occurred. Right now that looks like this:

var e *openapi3filter.RequestError
if goerrors.As(err, &e) {
	var e2 *openapi3.SchemaError
	if goerrors.As(e.Err, &e2) {
		path := e2.JSONPointer()
		fmt.Println(path)
	}
}

It could look like this:

var e *openapi3.SchemaError
if goerrors.As(err, &e) {
	path := e.JSONPointer()
	fmt.Println(path)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions