Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow checking gqlerror.List for wrapped errors with errors.Is and errors.As #147

Merged
merged 2 commits into from
Apr 7, 2021

Conversation

duckbrain
Copy link
Contributor

@duckbrain duckbrain commented Apr 2, 2021

errors.Is and errors.As will check if an error implements the interface and call the respective methods.

This allows checking if the list contains a sentinel error or getting one of a specific type. eg:

// err is a gqlerrors.List{&gqlerrors.Error{Error: services.ErrInvalidSession}}
if errors.Is(err, services.ErrInvalidSession) {
	// handle sentinel error
}

These functions weren't added to the standard library until 1.13, so this requires that version. This could maintain older Go compatibility by copying their implementations from 1.13 if we'd like to preserve the older version support.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 92.022% when pulling f66f07a on ec2-software:unwarp-error-list into 7e475a7 on vektah:master.

@lwc lwc merged commit b0c17ab into vektah:master Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants