How to properly wrap errors for stack-traces? #879
-
In go the following is quite common: err := someFunc(...)
if err != nil {
return fmt.Errorf("someFunc failed: %w", err)
} Now if we bubble these wrapped errors up and log them to sentry from a central place (e.g. echo error handler), we don't seem to receive a full stack-trace - it just points to the echo middleware and our custom error handler (which basically just tries to get the hub from the context and then logs the error using the current hub). Anything we have to do differently to get a readable stack-trace? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Have a look at https://docs.sentry.io/platforms/go/usage/#capturing-errors. |
Beta Was this translation helpful? Give feedback.
Have a look at https://docs.sentry.io/platforms/go/usage/#capturing-errors.
The TL;DR is to use a 3rd party library, such as https://github.com/go-errors/errors.