Documentation ¶
Index ¶
- func Assertf(cond bool, format string, options ...Option)
- func Errorf(format string, options ...Option) error
- func FormatStackTrace(callers []uintptr) []string
- func GetCallers(err error) []uintptr
- func IgnoreClose(c io.Closer)
- func MaybeMustWrap(err error, options ...Option)
- func MaybeWrap(err error, options ...Option) error
- func MaybeWrapRecover(r interface{}, options ...Option) error
- func MustClose(c io.Closer)
- func MustErrorf(format string, options ...Option)
- func MustWrap(err error, options ...Option)
- func Safe(f func() error) func() error
- func Unwrap(err error) error
- func Wrap(err error, options ...Option) error
- func WrapRecover(r interface{}, options ...Option) error
- type Args
- type ID
- type Metadata
- type Option
- type OptionFunc
- type Status
- type Summary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶
Errorf formats a new error and wraps it. Note: arguments implementing Option are applied on wrapping, the others are passed to fmt.Errorf().
func FormatStackTrace ¶
FormatStackTrace formats the given raw stack trace.
func GetCallers ¶
GetCallers returns the raw stack trace from the error, or the current raw stack trace if not found.
func IgnoreClose ¶
IgnoreClose calls Close on the given io.Closer, ignoring the returned error. Handy for the defer Close pattern.
func MaybeMustWrap ¶
MaybeMustWrap is like MustWrap, but does nothing if called with a nil error.
func MaybeWrapRecover ¶
MaybeWrapRecover is like WrapRecover but returns nil if called with a nil recover.
func MustClose ¶
MustClose calls Close on the given io.Closer, panicking in case of error. Handy for the defer Close pattern.
func MustErrorf ¶
MustErrorf is like Errorf but panics instead of returning the error.
func WrapRecover ¶
WrapRecover takes a recovered interface{} and converts it to a wrapped error.
Types ¶
type Args ¶
type Args []interface{}
Args describes a list of args used for formatting an error message.
type Metadata ¶
type Metadata map[string]interface{}
Metadata describes metadata which can be attached to errors.
func GetMetadata ¶
GetMetadata gets the metadata from the error, nil if not found.
type Option ¶
type Option interface {
Apply(err error)
}
Option describes an option which can be applied to an error.
type OptionFunc ¶
type OptionFunc func(err error)
OptionFunc describes an option which can be applied to an error.
func M ¶
func M(k string, v interface{}) OptionFunc
M is a shorthand for providing metadata to errors.
func Prefix ¶
func Prefix(format string, a ...interface{}) OptionFunc
Prefix adds a prefix to the error message.
func SkipAll ¶
func SkipAll() OptionFunc
SkipAll skips the caller and any lower frames from the stack trace.
func SkipPackage ¶ added in v1.1.0
func SkipPackage() OptionFunc
SkipPackage skips all frames from the caller package from the stack trace.
func (OptionFunc) Apply ¶
func (f OptionFunc) Apply(err error)
Apply implements the Option interface.
type Status ¶
type Status int
Status describes an HTTP status code.
type Summary ¶
type Summary struct { ID ID `json:"id,omitempty" yaml:"id,omitempty"` Status Status `json:"status,omitempty" yaml:"id,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"id,omitempty"` Message string `json:"message,omitempty" yaml:"id,omitempty"` StackTrace []string `json:"stackTrace,omitempty" yaml:"id,omitempty"` }
Summary provides a serializable summary of an error and its metadata.