Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MaxStackDepth = 50
The maximum number of stackframes on any error.
Functions ¶
func FormatCaller ¶
Formats program counter, file name, and line number information as returned by runtime.Caller()
Types ¶
type Error ¶
type Error struct { Err error // contains filtered or unexported fields }
Error is an error with an attached stacktrace. It can be used wherever the builtin error interface is expected.
func Append ¶
Appends one ore more suffixes to this error. Every suffix is prefixed with this prefix.
func Errorf ¶
Errorf creates a new error with the given message. You can use it as a drop-in replacement for fmt.Errorf() to provide descriptive errors in return values.
func New ¶
func New(e interface{}) *Error
New makes an Error from the given value. If that value is already an error then it will be used directly, if not, it will be passed to fmt.Errorf("%v"). The stacktrace will point to the line of code that called New.
func Wrap ¶
Wrap makes an Error from the given value. If that value is already an error then it will be used directly, if not, it will be passed to fmt.Errorf("%v"). The skip parameter indicates how far up the stack to start the stacktrace. 0 is from the current call, 1 from its caller, etc.
func (*Error) Callers ¶
Callers satisfies the bugsnag ErrorWithCallerS() interface so that the stack can be read out.
func (*Error) ErrorStack ¶
ErrorStack returns a string that contains both the error message and the callstack. The prefix parameter is used to add a prefix to the error message. The suffix parameter is used to add a suffix to the error message.
func (*Error) Stack ¶
Stack returns the callstack formatted the same way that go does in runtime/debug.Stack()
func (*Error) StackFrames ¶
func (err *Error) StackFrames() []StackFrame
StackFrames returns an array of frames containing information about the stack.
type StackFrame ¶
type StackFrame struct { // The path to the file containing this ProgramCounter File string // The LineNumber in that file LineNumber int // The Name of the function that contains this ProgramCounter Name string // The Package that contains this function Package string // The underlying ProgramCounter ProgramCounter uintptr }
A StackFrame contains all necessary information about to generate a line in a callstack.
func NewStackFrame ¶
func NewStackFrame(pc uintptr) (frame StackFrame)
NewStackFrame popoulates a stack frame object from the program counter.
func (*StackFrame) Func ¶
func (frame *StackFrame) Func() *runtime.Func
Func returns the function that contained this frame.
func (*StackFrame) SourceLine ¶
func (frame *StackFrame) SourceLine() (string, error)
SourceLine gets the line of code (from File and Line) of the original source if possible.
func (*StackFrame) String ¶
func (frame *StackFrame) String() string
String returns the stackframe formatted in the same way as go does in runtime/debug.Stack()