in strategy/exception/default_exception_formatting_strategy.go [146:198]
func (dEFS *DefaultFormattingStrategy) ExceptionFromError(err error) Exception {
var isRemote bool
var reqErr RequestFailure
if goerrors.As(err, &reqErr) {
// A service error occurs
if reqErr.RequestID() != "" {
isRemote = true
}
}
// Fetches type from err
t := fmt.Sprintf("%T", err)
// normalize the type
t = strings.Replace(t, "*", "", -1)
e := Exception{
ID: newExceptionID(),
Type: t,
Message: err.Error(),
Remote: isRemote,
}
xRayErr := &XRayError{}
if goerrors.As(err, &xRayErr) {
e.Type = xRayErr.Type
}
var s []uintptr
// This is our publicly supported interface for passing along stack traces
var st StackTracer
if goerrors.As(err, &st) {
s = st.StackTrace()
}
// We also accept github.com/pkg/errors style stack traces for ease of use
var est interface {
StackTrace() errors.StackTrace
}
if goerrors.As(err, &est) {
for _, frame := range est.StackTrace() {
s = append(s, uintptr(frame))
}
}
if s == nil {
s = make([]uintptr, dEFS.FrameCount)
n := runtime.Callers(5, s)
s = s[:n]
}
e.Stack = convertStack(s)
return e
}