errors

package
v2.0.0-...-d24bc72 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package errors implements functions to manipulate errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(f string, x ...interface{}) error

New formats a string according to the format specifier and arguments and returns an error that has a "proto" prefix.

Types

type NonFatal

type NonFatal struct{ E error }

NonFatal contains non-fatal errors, which are errors that permit execution to continue, but should return with a non-nil error. As such, NonFatal is a data structure useful for swallowing non-fatal errors, but being able to reproduce them at the end of the function. An error is non-fatal if it is collection of non-fatal errors, or is an individual error where IsRequiredNotSet or IsInvalidUTF8 reports true.

Typical usage pattern:

var nerr errors.NonFatal
...
if err := MyFunction(); !nerr.Merge(err) {
	return nil, err // immediately return if err is fatal
}
...
return out, nerr.E

func (*NonFatal) AppendInvalidUTF8

func (nf *NonFatal) AppendInvalidUTF8(field string)

AppendInvalidUTF8 appends an InvalidUTF8 error.

func (*NonFatal) AppendRequiredNotSet

func (nf *NonFatal) AppendRequiredNotSet(field string)

AppendRequiredNotSet appends a RequiredNotSet error.

func (*NonFatal) Merge

func (nf *NonFatal) Merge(err error) (ok bool)

Merge merges err into nf and reports whether it was successful. Otherwise it returns false for any fatal non-nil errors.

type NonFatalErrors

type NonFatalErrors []error

NonFatalErrors is a list of non-fatal errors where each error must either be a RequiredNotSet error or InvalidUTF8 error. The list must not be empty.

func (NonFatalErrors) Error

func (es NonFatalErrors) Error() string

Jump to

Keyboard shortcuts

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