Documentation
¶
Index ¶
- Constants
- Variables
- func New(msg string, args ...interface{}) error
- func PopStack(err error) error
- func RecoverPanic(r interface{}, errPtr *error)
- func Sentinel(msg string, args ...interface{}) error
- func Wrap(cause error, msg string, args ...interface{}) error
- type Item
- type Reason
- type Reasons
- type StackTrace
- type StackTracer
Constants ¶
const ( ValidationFailed = iota IntegrationNotFound StatusForbidden )
Variables ¶
var ( As = errors.As Is = errors.Is Cause = errors.Cause Unwrap = errors.Unwrap Join = baseerrors.Join )
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.
var DefaultReasons = Reasons{ ValidationFailed: { Status: http.StatusUnprocessableEntity, Key: "validation_failed", Description: "Validation failed", }, IntegrationNotFound: { Status: http.StatusNotImplemented, Key: "integration_not_found", Description: "Integration not found", }, StatusForbidden: { Status: http.StatusForbidden, Key: "forbidden_request", Description: "Forbidden Request", }, }
Functions ¶
func New ¶
New acts as pkg/errors.New does, producing a stack traced error, but supports interpolating of message parameters. Use this when you want the stack trace to start at the place you create the error.
func RecoverPanic ¶
func RecoverPanic(r interface{}, errPtr *error)
RecoverPanic turns a panic into an error, adjusting the stacktrace so it originates at the line that caused it.
Example:
func Do() (err error) {
defer func() {
errors.RecoverPanic(recover(), &err)
}()
}
func Sentinel ¶
Sentinel is used to create compile-time errors that are intended to be value only, with no associated stack trace.
func Wrap ¶
Wrap creates a new error from a cause, decorating the original error message with a prefix.
It differs from the pkg/errors Wrap/Wrapf by idempotently creating a stack trace, meaning we won't create another stack trace when there is already a stack trace present that matches our current program position.
Types ¶
type StackTrace ¶
type StackTrace = errors.StackTrace
StackTrace should be aliases rather than newtype'd, so it can work with any of the functions we export from pkg/errors.
type StackTracer ¶
type StackTracer interface {
StackTrace() errors.StackTrace
}