in errortracking/sentry_tracker.go [57:89]
func attachExceptions(event *sentry.Event, err error) {
if err == nil {
return
}
for i := 0; i < maxErrorDepth && err != nil; i++ {
event.Exception = append(event.Exception, sentry.Exception{
Value: err.Error(),
Type: reflect.TypeOf(err).String(),
Stacktrace: sentry.ExtractStacktrace(err),
})
switch previous := err.(type) {
case interface{ Unwrap() error }:
err = previous.Unwrap()
case interface{ Cause() error }:
err = previous.Cause()
default:
err = nil
}
}
// Add a trace of the current stack to the most recent error in a chain if
// it doesn't have a stack trace yet.
// We only add to the most recent error to avoid duplication and because the
// current stack is most likely unrelated to errors deeper in the chain.
if event.Exception[0].Stacktrace == nil {
event.Exception[0].Stacktrace = sentry.NewStacktrace()
}
// event.Exception should be sorted such that the most recent error is last.
reverse(event.Exception)
}