-
Notifications
You must be signed in to change notification settings - Fork 52
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
Unpack external errors (especially coming from pkg/errors) #37
Comments
I think while writing the A potential solution could be to discard the stack of this error but recursively A concocted example:
The stack trace in the proposed output when printing err with trace would probably be misleading as the original stack trace was lost while wrapping the external error. Personally, to have a coherent solution is preferable over something which is half right. |
Thank you for checking so quickly. To give a little more context: The output you describe as proposed implementation is actually the output I currently get from
Again, I'm only working with the JSON output not the typical text output of the error. Was just hoping to get the external error as a separate entries in the JSON instead of one long item with a concatenated string. |
@dnaka91 I like this idea! I think this is possibly something we can do, but I want to test some things out over the next few days. |
@dnaka91 I got what you meant! I misunderstood the initial question. Perhaps we can look into getting frames and stack trace from errors defined by pkg/errors. Although doing it for other error libraries might be an impossible task. |
@dnaka91 Just curious as to why would you not completely switch to eris and rather handle errors via two separate libraries? |
Hey @sum2000, sorry for the late answer, I was on vacation. Switching completely within the single project is not a big deal and I already did that on a separate branch for the purpose of evaluating this error library. The trouble are generators and 3rd party libraries.
|
@dnaka91 thanks for the followup. The reasons you mentioned suffice for supporting the trace inter-op between |
Is your feature request related to a problem? Please describe.
When getting errors from other libraries that use
github.com/pkg/errors
or forks of it, I noticed that the error is just flattened by callingerror.Error()
and then returning arootError
.This is fine for custom errors, but
pkg/errors
is very widespread and integration with it would make the created errors more complete.Describe the solution you'd like
It would be nice if
eris
tries to unpack the error instead of just turning it into string, by recursively callingUnpack
. Aspkg/errors
is very popular, checking for the oldfunc Cause() error
in addition tofunc Unpack() error
would be great.Not just errors from
pkg/errors
but any error in general that implementsUnpack
makes sense to unpack in my opinion.Not sure how to unmangle the stack trace though.
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: