Skip to content

Commit

Permalink
Revert to PC after breaking change in pkg/errors was reverted
Browse files Browse the repository at this point in the history
A more recent [PR](pkg/errors#193) on pkg/errors
reverts usage of runtime.Frame after complaints about [breaking
change](pkg/errors#183).
  • Loading branch information
Mohamad mehdi Kharatizadeh committed Jan 9, 2019
1 parent af3520b commit f2384dd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sentry.go
Expand Up @@ -3,6 +3,7 @@ package logrus_sentry
import (
"encoding/json"
"fmt"
"runtime"
"sync"
"time"

Expand Down Expand Up @@ -309,9 +310,11 @@ func (hook *SentryHook) convertStackTrace(st errors.StackTrace) *raven.Stacktrac
stConfig := &hook.StacktraceConfiguration
stFrames := []errors.Frame(st)
frames := make([]*raven.StacktraceFrame, 0, len(stFrames))
for _, stFrame := range stFrames {
frame := raven.NewStacktraceFrame(stFrame.PC, stFrame.Func.Name(), stFrame.File, stFrame.Line,
stConfig.Context, stConfig.InAppPrefixes)
for i := range stFrames {
pc := uintptr(stFrames[i])
fn := runtime.FuncForPC(pc)
file, line := fn.FileLine(pc)
frame := raven.NewStacktraceFrame(pc, fn.Name(), file, line, stConfig.Context, stConfig.InAppPrefixes)
if frame != nil {
frames = append(frames, frame)
}
Expand Down

0 comments on commit f2384dd

Please sign in to comment.