-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Can you add LastPublic(), LastCode() API? #34
Comments
I consider the most nested error to be the most accurate, and higher levels have less information about the error context. Can you write a short example where the overwrite takes precedence ? I wonder if a more general approach would be to add a method |
In the following short example, I only want to throw a code or msg that can be opened to the outside world to hide the internal error, because I will record detailed information in the final unified error handling. func api(){
return oops.Code("public code").Public("public msg").Wrap(service())
}
func service()err{
return oops.Code("1").Errorf("e")
} |
I think in an ideal state, each layer of error is only responsible for processing its own information, so through Unwrap(), you can handle errors at each layer at will while retaining the stack information |
I noticed that when calling Public(), Code(), the deepest public/code value will be obtained, but the business often overwrites the bottom layer information, and the top layer information is needed in the final output.
When I handle errors, I usually recursively obtain stack information. The current API does not allow me to obtain error information at each layer.
The text was updated successfully, but these errors were encountered: