Skip to content

Commit

Permalink
A small bugfix to create valid stacktraces (#28)
Browse files Browse the repository at this point in the history
raven.NewStacktraceFrame() ignores frames for `runtime.goexit`, which lead
to null values in stack traces, which sentry doesn't like.  This fixes the
oversight.
  • Loading branch information
flimzy authored and evalphobia committed Dec 15, 2016
1 parent d5bbafe commit 3d7f059
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ func (hook *SentryHook) convertStackTrace(st errors.StackTrace) *raven.Stacktrac
pc := uintptr(stFrames[i])
fn := runtime.FuncForPC(pc)
file, line := fn.FileLine(pc)
frames = append(frames, raven.NewStacktraceFrame(pc, file, line, stConfig.Context, stConfig.InAppPrefixes))
frame := raven.NewStacktraceFrame(pc, file, line, stConfig.Context, stConfig.InAppPrefixes)
if frame != nil {
frames = append(frames, frame)
}
}
return &raven.Stacktrace{Frames: frames}
}
Expand Down
2 changes: 1 addition & 1 deletion sentry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func TestSentryStacktrace(t *testing.T) {
frames = packet.Exception.Stacktrace.Frames
}
expectedPkgErrorsStackTraceFilename := "github.com/evalphobia/logrus_sentry/sentry_test.go"
expectedFrameCount := 5
expectedFrameCount := 4
expectedCulprit = "errorX"
if packet.Culprit != expectedCulprit {
t.Errorf("Expected culprit of '%s', got '%s'", expectedCulprit, packet.Culprit)
Expand Down

0 comments on commit 3d7f059

Please sign in to comment.