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

Implement "Is()" For Error Type #30

Closed
tri-adam opened this issue Jul 7, 2020 · 0 comments · Fixed by #32
Closed

Implement "Is()" For Error Type #30

tri-adam opened this issue Jul 7, 2020 · 0 comments · Fixed by #32
Assignees

Comments

@tri-adam
Copy link
Member

tri-adam commented Jul 7, 2020

We should implement the Is() method introduced in Go 1.13 for the jsonresp.Error type in order to make it more usable. I propose the implementation takes the approach similar to the example in the Working with Errors in Go 1.13 blog post, comparing non-zero fields.

This would allow succinct code such as the following:

if errors.Is(err, &jsonresp.Error{Code: http.StatusUnauthorized}) {
	// Do some stuff...
}
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 a pull request may close this issue.

1 participant