-
Notifications
You must be signed in to change notification settings - Fork 8
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
[Proposal] No way to check the cause if using a mix of go-errors and standard errors #12
Comments
This looks very similar to the semantics of the current error inspection proposal implemented by https://godoc.org/golang.org/x/xerrors. |
Yup, this and the other proposal are basically bringing the good bits of xerrors to go-errors so the library it’s more stderror friendly
…On 2 Aug 2019, 21:04 +0200, M. J. Fromberger ***@***.***>, wrote:
This looks very similar to the semantics of the current error inspection proposal implemented by https://godoc.org/golang.org/x/xerrors.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
That makes sense. But I wonder if it's possible to do so by integrating with the |
Yeah, implementing |
That makes sense. You might consider using the same name, though, so that |
By the way, the standard library already has an |
Fair enough.
It wasn't because of adding size to the binary. It was because when using go-errors, one should not need to use any other library for error handling, since all needed features are expected to be provided by the library. |
Let's imagine we are using a mix of this library and standard errors created with
errors.New
orfmt.Errorf
.Consider the following snippet:
If we want to check if myErr has
errStd
as its cause, we need to do the following:This is potentially more cumbersome if the original error is deeply nested.
Perhaps we could have a function
IsCausedBy(err, cause)
.In this case, it would become:
Implementation could look like this:
The text was updated successfully, but these errors were encountered: