...
1 package bugsnaghandler
2
3 import (
4 berrors "github.com/bugsnag/bugsnag-go/errors"
5 "github.com/pkg/errors"
6 )
7
8 type stackTracer interface {
9 Error() string
10 StackTrace() errors.StackTrace
11 }
12
13 type errorWithStackFrames struct {
14 err stackTracer
15 }
16
17
18
19 func newErrorWithStackFrames(err stackTracer) *errorWithStackFrames {
20 return &errorWithStackFrames{err}
21 }
22
23
24 func (e *errorWithStackFrames) Error() string {
25 return e.err.Error()
26 }
27
28
29 func (e *errorWithStackFrames) Cause() error {
30 return e.err
31 }
32
33
34 func (e *errorWithStackFrames) StackTrace() errors.StackTrace {
35 return e.err.StackTrace()
36 }
37
38 func (e *errorWithStackFrames) StackFrames() []berrors.StackFrame {
39 stackTrace := e.err.StackTrace()
40 stackFrames := make([]berrors.StackFrame, len(stackTrace))
41
42 for i, frame := range stackTrace {
43 stackFrames[i] = berrors.NewStackFrame(uintptr(frame))
44 }
45
46 return stackFrames
47 }
48
View as plain text