getsentry / raven-go

Sentry client in Go
https://sentry.io
BSD 3-Clause "New" or "Revised" License
561 stars 148 forks source link

`CaptureError` sends stacktrace of `Cause()` #214

Open femaref opened 6 years ago

femaref commented 6 years ago

Right now, if your error is the following:

import "github.com/pkg/errors"
...
    return errors.WithStack(err)
...

it will not use that stacktrace. The reason is in client.go:

https://github.com/getsentry/raven-go/blob/3033899c76deb3fb6570d9c4074d00443aeab88f/client.go#L710-L712

cause gets used for the Stacktrace generation. However, Cause is called on the result of errors.WithStack, which simply removes that layer, so we don't have a trace anymore.

Is there a reason why Cause is used here? Maybe instead of always taking the Cause, check if the current err has a Stacktrace and cause has not, and use the stack of err?

femaref commented 6 years ago

pr: https://github.com/getsentry/raven-go/pull/215