package errors
import "github.com/bugsnag/bugsnag-go/errors"
Package errors provides errors that have stack-traces.
Index ¶
- Variables
- type Error
- func Errorf(format string, a ...interface{}) *Error
- func New(e interface{}, skip int) *Error
- func ParsePanic(text string) (*Error, error)
- func (err *Error) Error() string
- func (err *Error) Stack() []byte
- func (err *Error) StackFrames() []StackFrame
- func (err *Error) TypeName() string
- type StackFrame
Variables ¶
var MaxStackDepth = 50
The maximum number of stackframes on any error.
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 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 ¶
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 skip parameter indicates how far up the stack to start the stacktrace. 0 is from the current call, 1 from its caller, etc.
func ParsePanic ¶
ParsePanic allows you to get an error object from the output of a go program that panicked. This is particularly useful with https://github.com/mitchellh/panicwrap.
func (*Error) Error ¶
Error returns the underlying error's 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.
func (*Error) TypeName ¶
TypeName returns the type this error. e.g. *errors.stringError.
type StackFrame ¶
type StackFrame struct { File string LineNumber int Name string Package string 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 this stackframe corresponds to
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()
Source Files ¶
error.go parse_panic.go stackframe.go
- Version
- v1.0.4
- Published
- May 28, 2015
- Platform
- js/wasm
- Imports
- 7 packages
- Last checked
- 1 hour ago –
Tools for package owners.