errors package - github.com/coditory/go-errors - Go Packages

This section is empty.

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.

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(action func()) error

Recover executes a function and turns a panic into an error.

Example:

err := errors.Recover(func() {
  somePanicingLogic()
})
func RecoverPanic(r interface{}, errPtr *error)

RecoverPanic turns a panic into an error.

Example:

func Do() (err error) {
  defer func() {
    errors.RecoverPanic(recover(), &err)
  }()
}
func New(msg string, args ...interface{}) *Error

Creates a new error with a stack trace. Supports interpolating of message parameters.

Example: err := err.New("error %d", 42) err.Error() == "error 42"

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(err error, msgAndArgs ...interface{}) *Error

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 (e *Error) StackTrace() StackTrace
func (e *Error) StackTraceString(verbosity int) string

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.

File returns the full path to the File that contains the function for this Frame's pc.

func (f Frame) FileLine() int

FileLine returns the FileLine number of source code of the function for this Frame's pc.

FuncName returns the FuncName of this function, if known.

Pc returns the program counter for this frame; multiple frames may have the same PC value.

file name relateive to BasePath or BaseCachePath

function name relative to main package

function name relative to main package

StackTrace is stack of Frames from innermost (newest) to outermost (oldest).