Package errors
Overview ▹
▹ Example (StackTrace)
Index ▹
func Cause ¶
func Cause(err error) error
Cause returns the underlying cause of the error, if possible. An error value has a cause if it implements the following interface:
type causer interface { Cause() error }
If the error does not implement Cause, the original error will be returned. If the error is nil, nil will be returned without further investigation.
▹ Example
▹ Example (Printf)
func Errorf ¶
func Errorf(format string, args ...interface{}) error
Errorf formats according to a format specifier and returns the string as a value that satisfies error. Errorf also records the stack trace at the point it was called.
▹ Example (Extended)
func New ¶
func New(message string) error
New returns an error with the supplied message. New also records the stack trace at the point it was called.
▹ Example
▹ Example (Printf)
func WithMessage ¶
func WithMessage(err error, message string) error
WithMessage annotates err with a new message. If err is nil, WithMessage returns nil.
▹ Example
func WithStack ¶
func WithStack(err error) error
WithStack annotates err with a stack trace at the point WithStack was called. If err is nil, WithStack returns nil.
▹ Example
▹ Example (Printf)
func Wrap ¶
func Wrap(err error, message string) error
Wrap returns an error annotating err with a stack trace at the point Wrap is called, and the supplied message. If err is nil, Wrap returns nil.
▹ Example
▹ Example (Extended)
func Wrapf ¶
func Wrapf(err error, format string, args ...interface{}) error
Wrapf returns an error annotating err with a stack trace at the point Wrapf is call, and the format specifier. If err is nil, Wrapf returns nil.
▹ Example
type Frame ¶
Frame represents a program counter inside a stack frame.
type Frame uintptr
func (Frame) Format ¶
func (f Frame) Format(s fmt.State, verb rune)
Format formats the frame according to the fmt.Formatter interface.
%s source file %d source line %n function name %v equivalent to %s:%d
Format accepts flags that alter the printing of some verbs, as follows:
%+s path of source file relative to the compile time GOPATH %+v equivalent to %+s:%d
type StackTrace ¶
StackTrace is stack of Frames from innermost (newest) to outermost (oldest).
type StackTrace []Frame
func (StackTrace) Format ¶
func (st StackTrace) Format(s fmt.State, verb rune)