-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.go
47 lines (37 loc) · 1.15 KB
/
error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package bugsnag
import (
berrors "github.com/bugsnag/bugsnag-go/errors"
"github.com/pkg/errors"
)
type stackTracer interface {
Error() string
StackTrace() errors.StackTrace
}
type errorWithStackFrames struct {
err stackTracer
}
// newErrorWithStackFrames returns a new error implementing the
// github.com/bugsnag/bugsnag-go/errors.ErrorWithStackFrames interface.
func newErrorWithStackFrames(err stackTracer) *errorWithStackFrames {
return &errorWithStackFrames{err}
}
// Error implements the error interface.
func (e *errorWithStackFrames) Error() string {
return e.err.Error()
}
// Cause implements the github.com/pkg/errors.causer interface.
func (e *errorWithStackFrames) Cause() error {
return e.err
}
// StackTrace implements the github.com/pkg/errors.stackTracer interface.
func (e *errorWithStackFrames) StackTrace() errors.StackTrace {
return e.err.StackTrace()
}
func (e *errorWithStackFrames) StackFrames() []berrors.StackFrame {
stackTrace := e.err.StackTrace()
stackFrames := make([]berrors.StackFrame, len(stackTrace))
for i, frame := range stackTrace {
stackFrames[i] = berrors.NewStackFrame(uintptr(frame))
}
return stackFrames
}