Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( As = errors.As Unwrap = errors.Unwrap )
Export a number of functions or variables from pkg/errors. We want people to be able to use them, if only via the entrypoints we've vetted in this file.
Functions ¶
func Is ¶
Detects whether the error is equal to a given error. Errors are considered equal by this function if they are matched by errors.Is or if their contained errors are matched through errors.Is
func Recover ¶ added in v0.0.3
func Recover(action func()) error
Recover executes a function and turns a panic into an error.
Example:
err := errors.Recover(func() { somePanicingLogic() })
func RecoverPanic ¶
func RecoverPanic(r interface{}, errPtr *error)
RecoverPanic turns a panic into an error.
Example:
func Do() (err error) { defer func() { errors.RecoverPanic(recover(), &err) }() }
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func New ¶
Creates a new error with a stack trace. Supports interpolating of message parameters.
Example: err := err.New("error %d", 42) err.Error() == "error 42"
func Prefix ¶ added in v0.0.3
Similiar to wrap. Creates a new error with message that prefixes wrapped errro. Supports interpolating of message parameters.
Example: wrapped := fmt.Errorf("wrapped") err := errors.Prefix(wrapped, "errored happened") err.Error() == "error happened: wrapped" err.Unwrap() == wrapped
func Wrap ¶
Creates a new error with a cause and a stack trace. Supports interpolating of message parameters.
Example: wrapped := fmt.Errorf("wrapped") err := errors.wrap(wrapped, "errored happened") err.Error() == "error happened" err.Unwrap() == wrapped
func (*Error) StackTrace ¶
func (e *Error) StackTrace() StackTrace
func (*Error) StackTraceString ¶ added in v0.0.2
type Frame ¶
type Frame uintptr
Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as a uintptr its value represents the program counter + 1.
func (Frame) File ¶ added in v0.0.2
File returns the full path to the File that contains the function for this Frame's pc.
func (Frame) Line ¶ added in v0.0.2
Line returns the Line number of source code of the function for this Frame's pc.
func (Frame) Pc ¶ added in v0.0.2
Pc returns the program counter for this frame; multiple frames may have the same PC value.
func (Frame) RelFuncName ¶ added in v0.0.2
function name relative to main package
type StackTrace ¶
type StackTrace []Frame
StackTrace is stack of Frames from innermost (newest) to outermost (oldest).