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

Consider using errors.As instead of type assertions in segment.Close to support wrapped errors #352

Open
okonos opened this issue Mar 30, 2022 · 0 comments
Assignees

Comments

@okonos
Copy link
Contributor

okonos commented Mar 30, 2022

Segment.Close enriches the segment with details specific to the error passed, but since it uses type assertions, the error must be of an exact type:

if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurs
if reqErr.RequestID() != "" {
isRemote = true
}
}

if err, ok := err.(*XRayError); ok {
e.Type = err.Type
}

if err, ok := err.(StackTracer); ok {
s = err.StackTrace()
}

Using errors.As there instead of type assertions would make it work with wrapped errors as well.

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

No branches or pull requests

2 participants