errmap

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2021 License: Apache-2.0 Imports: 2 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(err error) error

Apply invokes all of the mappers that have been added to the given error and returns the resulting error.

Once Apply has been called for an error, the mapping chain is reset.

func MapAfter

func MapAfter(err error, m Mapper) error

MapAfter causes the given mapper to run just after any mappers added by calling MapBefore in an error mapping chain.

func MapBefore

func MapBefore(err error, m Mapper) error

MapBefore causes the given mapper to run just before any mappers added by calling MapAfter in an error mapping chain.

func MapFirst

func MapFirst(err error, m Mapper) error

MapFirst causes the given mapper to run at the very beginning of an error mapping chain.

func MapLast

func MapLast(err error, m Mapper) error

MapLast causes the given mapper to run at the very end of an error mapping chain.

func Wrap

func Wrap(err error, message string) error

Wrap causes the given message to be prepended to the error at the end of the error mapping chain.

Types

type MapApplicator

type MapApplicator interface {
	MapApply(m Mapper) error
}

MapApplicator allows an error to control mapping behavior.

An implementor of MapApplicator generally maps a delegate error and then determines what action it needs to take. For example, it may choose to merge the resulting error with itself, or may opt to take no action at all.

Each error that is mapped by this package is tested to see if it implements MapApplicator before Mappers are called.

type Mapper

type Mapper interface {
	Map(err error) error
}

Mapper constructs a new error from a given error.

Generally, a mapped error should provied an Unwrap method to access the underlying error unless it is deliberately hiding it (because of an API boundary, for example).

type MapperFunc

type MapperFunc func(err error) error

MapperFunc allows a function to be used as a Mapper.

func (MapperFunc) Map

func (mf MapperFunc) Map(err error) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL