multierror

package
v0.0.0-...-1480658 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(errs []error) error

New creates a MultiError from a list of errors.

This is just a convenience wrapper to ensure that if there is no error, if errs has len() == 0, or all errors are nil, nil is returned.

In facts, you could normally convert a []error{} into a MultiError by simply using a cast: MultiError(errs). However, a simple cast would lead to a non nil error when errs has lenght 0.

func NewOr

func NewOr(errs []error, fallback error) error

NewOr creates a MultiError from a list of errors, or returns the fallback error.

Just like New, but gurantees that an error is returned. If the list of errors is empty, it will return the supplied error instead.

Types

type MultiError

type MultiError []error

func (MultiError) As

func (me MultiError) As(target interface{}) bool

As for MultiError returns the first error that can be considered As the specified target.

func (MultiError) Error

func (me MultiError) Error() string

func (MultiError) Is

func (me MultiError) Is(target error) bool

Is for MultiError returns true if any of the errors listed can be considered of the target type.

func (MultiError) Unwrap

func (me MultiError) Unwrap() error

Unwrap for MultiError always returns nil, as there is no reasonable way to implement it.

Use As and Is methods, or loop over the list directly to access the underlying errors.

Jump to

Keyboard shortcuts

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