Documentation
¶
Overview ¶
Package errors extends the errors package in the stdlib.
Despite the implicit nature of interface satisfication in Go this package exports a number of interfaces to avoid defining them over and over again. Although it means coupling between the consumer code and this package, the purpose of this library (being a stdlib extension) justifies that.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cause ¶
Cause returns the underlying cause of the error, if possible. An error value has a cause if it implements the Causer interface.
If the error does not implement Cause, the original error will be returned. If the error is nil, nil will be returned without further investigation.
This is an alias to github.com/pkg/errors.Cause function.
func New ¶
New returns an error that formats as the given text.
This is an alias to the stdlib errors.New function.
func NewWithStackTrace ¶
NewWithStackTrace returns an error that formats as the given text and contains stack trace.
This is an alias to github.com/pkg/errors.New function.
func Recover ¶
func Recover(r interface{}) (err error)
Recover accepts a recovered panic (if any) and converts it to an error (if necessary).
func WithMessage ¶
WithMessage annotates err with a new message.
If err is nil, WithMessage returns nil.
This is an alias to github.com/pkg/errors.WithMessage function.
Types ¶
type Causer ¶
type Causer interface {
Cause() error
}
Causer is the interface defined in github.com/pkg/errors for specifying a parent error.
type Contextor ¶
type Contextor interface {
Context() []interface{}
}
Contextor represents an error which holds a context.
type ErrorCollection ¶
type ErrorCollection interface {
Errors() []error
}
ErrorCollection holds a list of errors.
type Handler ¶
type Handler interface { // Handle processes an error. Handle(err error) }
Handler is responsible for handling an error.
This interface allows libraries to decouple from logging and error handling solutions.
type StackTracer ¶
type StackTracer interface {
StackTrace() errors.StackTrace
}
StackTracer is the interface defined in github.com/pkg/errors for exposing stack trace from an error.