errors

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: Apache-2.0 Imports: 4 Imported by: 32

README

errors

CircleCI Go Report Card

errors provides utility routines for working with errors that are compatible with go 1.13+.

It currently provides:

  1. errors.M which can be used to store multiple error values. errors.M is thread safe.
errs := errors.M{}
...
errs.Append(fn(a))
...
errs.Append(fn(b))
...
err := errs.Err()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target interface{}) bool

As calls errors.As.

func Is

func Is(err, target error) bool

Is calls errors.Is.

func New

func New(m string) error

New calls errors.New.

func Unwrap

func Unwrap(err error) error

Unwrap calls errors.Unwrap.

Types

type M

type M struct {
	// contains filtered or unexported fields
}

M represents multiple errors. It is thread safe. Typical usage is:

errs := errors.M{} ... errs.Append(err) ... return errs.Err()

func (*M) Append

func (m *M) Append(errs ...error)

Append appends the specified errors excluding nil values.

func (*M) As

func (m *M) As(target interface{}) bool

As supports errors.As.

func (*M) Clone

func (m *M) Clone() *M

Clone returns a new errors.M that contains the same errors as itself.

func (*M) Err

func (m *M) Err() error

Err returns nil if m contains no errors, or itself otherwise.

func (*M) Error

func (m *M) Error() string

Error implements error.error

func (*M) Format

func (m *M) Format(f fmt.State, c rune)

Format implements fmt.Formatter.Format.

func (*M) Is

func (m *M) Is(target error) bool

Is supports errors.Is.

func (*M) Unwrap

func (m *M) Unwrap() error

Unwrap implements errors.Unwrap. It returns the first stored error and then removes that error.

Jump to

Keyboard shortcuts

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