package
0.110.0
Repository: https://github.com/openmfp/golang-commons.git
Documentation: pkg.go.dev

# README

OpenMFP Errors

The errors package is a drop-in replacement for the stdlib errors package but enhances all errors with a stacktrace. This is especially useful in combination with Sentry as it implements the StackFrames() function that the Sentry SDK uses to collect data to show a call history.

Usage

This package can be used like the default stdlib errors package. Just switch the import from errors to github.com/openmfp/golang-commons/errors.

Instead of fmt.Errorf() to wrap errors you can use the errors.Errorf() function from this package or the helper functions errors.Wrap() or errors.Wrapf(). All of the above return an error with attached stack trace.

To add the current stacktrace to an existing error use the errors.WithStack() util function.

# Functions

EnsureStack checks if error has a stack, if not adds stack information, otherwise leaves the error unmodified.
New acts as pkg/errors.New does, producing a stack traced error, but supports interpolating of message parameters.
No description provided by the author
PopStack removes the top of the stack from an errors stack trace.
Sentinel is used to create compile-time errors that are intended to be value only, with no associated stack trace.
Wrap creates a new error from a cause, decorating the original error message with a prefix.

# Variables

Export a number of functions or variables from pkg/errors.
Export a number of functions or variables from pkg/errors.
Export a number of functions or variables from pkg/errors.
Export a number of functions or variables from pkg/errors.
Export a number of functions or variables from pkg/errors.

# Interfaces

No description provided by the author
No description provided by the author

# Type aliases

StackTrace should be aliases rather than newtype'd, so it can work with any of the functions we export from pkg/errors.