Documentation
¶
Overview ¶
Package errors extends the errors package in the stdlib.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrorCollection ¶ added in v0.4.0
type ErrorCollection interface {
Errors() []error
}
ErrorCollection holds a list of errors.
type MultiError ¶ added in v0.4.0
type MultiError struct {
// contains filtered or unexported fields
}
MultiError aggregates multiple errors into a single value.
While ErrorCollection is only an interface for listing errors, MultiError actually implements the error interface so it can be returned as an error.
func (*MultiError) Error ¶ added in v0.4.0
func (e *MultiError) Error() string
Error implements the error interface.
func (*MultiError) Errors ¶ added in v0.4.0
func (e *MultiError) Errors() []error
Errors returns the list of wrapped errors.
type MultiErrorBuilder ¶ added in v0.4.0
type MultiErrorBuilder struct {
SingleWrapMode SingleWrapMode
// contains filtered or unexported fields
}
MultiErrorBuilder provides an interface for aggregating errors and exposing them as a single value.
func NewMultiErrorBuilder ¶ added in v0.4.0
func NewMultiErrorBuilder() *MultiErrorBuilder
NewMultiErrorBuilder returns a new MultiErrorBuilder.
func (*MultiErrorBuilder) Add ¶ added in v0.4.0
func (b *MultiErrorBuilder) Add(err error)
Add adds an error to the list.
Calling this method concurrently is not safe.
func (*MultiErrorBuilder) ErrOrNil ¶ added in v0.4.0
func (b *MultiErrorBuilder) ErrOrNil() error
ErrOrNil returns a MultiError the builder aggregates a list of errors, or returns nil if the list of errors is empty.
It is useful to avoid checking if there are any errors added to the list.
type SingleWrapMode ¶ added in v0.4.0
type SingleWrapMode int
SingleWrapMode defines how MultiErrorBuilder behaves when there is only one error in the list.
const ( AlwaysWrap SingleWrapMode = iota // Always return a MultiError. ReturnSingle // Return the single error. )
These constants cause MultiErrorBuilder to behave as described if there is only one error in the list.