Skip to content

Commit 13ba927

Browse files
bradleyfalzonevalphobia
authored andcommitted
Stacktrace the culprit should be the received error not the cause (#45)
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.
1 parent 9f8f2d0 commit 13ba927

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

sentry.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ func (hook *SentryHook) Fire(entry *logrus.Entry) error {
197197
if currentStacktrace == nil {
198198
currentStacktrace = raven.NewStacktrace(stConfig.Skip, stConfig.Context, stConfig.InAppPrefixes)
199199
}
200-
err := errors.Cause(err)
201-
exc := raven.NewException(err, currentStacktrace)
200+
exc := raven.NewException(errors.Cause(err), currentStacktrace)
202201
if !stConfig.SendExceptionType {
203202
exc.Type = ""
204203
}

sentry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func TestSentryStacktrace(t *testing.T) {
300300
if packet.Exception.Stacktrace != nil {
301301
frames = packet.Exception.Stacktrace.Frames
302302
}
303-
expectedCulprit := "myStacktracerError!"
303+
expectedCulprit := "wrapped: myStacktracerError!"
304304
if packet.Culprit != expectedCulprit {
305305
t.Errorf("Expected culprit of '%s', got '%s'", expectedCulprit, packet.Culprit)
306306
}

0 commit comments

Comments
 (0)