errs

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2020 License: Apache-2.0 Imports: 3 Imported by: 4

Documentation

Overview

Package errs provides error wrapping functions that allow an error to wrap multiple other errors. The error wrapping in the Go standard library allows an error to wrap only one error with only one %w format verb in the format string passed to fmt.Errorf and the errors.Unwrap() function that returns only a single error.

The error type returned by the functions in this package wraps multiple errors so that errors.Is() and errors.As() can be used to query if that error is any one of the wrapped errors. errors.Unwrap() on errors of that type always returns nil as that function cannot return multiple errors.

The error type is not exported so is used through the standard Go error interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(format string, args ...interface{}) error

Errorf returns an error formatted with a format string and arguments, similar to how fmt.Errorf works. The error returned by Errorf wraps each argument that is an error type unless that error argument is marked with the Nowrap() function. The %w format verb should not be used in the format string.

func New

func New(errs ...error) error

New takes a variable number of input errors and returns an error that is formatted as the concatenation of the string form of each input error, separated by a colon and space. The returned error wraps each input error.

For example New(err1, err2, err3) is formatted as

err1: err2: err3

func NoWrap

func NoWrap(err error) noWrap

NoWrap marks errors not to be wrapped for Errorf.

Types

This section is empty.

Jump to

Keyboard shortcuts

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