Skip to content

Commit

Permalink
Stacktrace the culprit should be the received error not the cause (#45)
Browse files Browse the repository at this point in the history
Previously, when stacktrace was enabled, the culprit would be set to
the first error that did not implement Cause (as detected by errors.Cause(err)),
this had the affect of not showing any additional context added to
the error.

This was also inconsistent with the same behaviour when stacktrace was
disabled.

This change attempts to unify that behaviour, as well as to not discard
the context added to the errors.
  • Loading branch information
bradleyfalzon authored and evalphobia committed Aug 30, 2017
1 parent 9f8f2d0 commit 13ba927
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ func (hook *SentryHook) Fire(entry *logrus.Entry) error {
if currentStacktrace == nil {
currentStacktrace = raven.NewStacktrace(stConfig.Skip, stConfig.Context, stConfig.InAppPrefixes)
}
err := errors.Cause(err)
exc := raven.NewException(err, currentStacktrace)
exc := raven.NewException(errors.Cause(err), currentStacktrace)
if !stConfig.SendExceptionType {
exc.Type = ""
}
Expand Down
2 changes: 1 addition & 1 deletion sentry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func TestSentryStacktrace(t *testing.T) {
if packet.Exception.Stacktrace != nil {
frames = packet.Exception.Stacktrace.Frames
}
expectedCulprit := "myStacktracerError!"
expectedCulprit := "wrapped: myStacktracerError!"
if packet.Culprit != expectedCulprit {
t.Errorf("Expected culprit of '%s', got '%s'", expectedCulprit, packet.Culprit)
}
Expand Down

0 comments on commit 13ba927

Please sign in to comment.