Skip to content

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

@okonos

Description

@okonos

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions