errors

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package errors implements some utility functions for giving detailed errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

Cause recurses down the given error, if it is Error, to find the underlying Err that triggered it.

func Err

func Err(err error) error

Err wraps the given error in the context in which it occurred. If the given err is nil then nil is returned.

func Is added in v1.1.0

func Is(err, target error) bool

Is reports whether any error in err's chain matches target. This calls errors.Is from the stdlib.

func MultiError

func MultiError(err ...error) error

MultiError returns a concatenation of the given errors.

func New

func New(s string) error

New returns a simple string error. This is equivalent to the errors.New function from the stdlib.

func Unwrap added in v1.1.0

func Unwrap(err error) error

Unwrap returns the result of calling the Unwrap method on err, if err's type contains an Unwrap method returning error. This calls errors.Unwrap from the stdlib.

Types

type Error

type Error struct {
	Err  error  // Err is the underlying error that occured.
	Func string // Func is the name of the calling function that triggered the error.
	File string // File is the source file where the error occured.
	Line int    // Line is the line number in the source file where the error occurred.
}

Error implements the builtin error interface. This captures information about the underlying error itself, and where the error occurred.

func (*Error) Error

func (e *Error) Error() string

Error returns the full "stacktrace" of the error using the context data about that error.

func (*Error) Unwrap added in v1.1.0

func (e *Error) Unwrap() error

Unwrap returns the underlying error.

type Slice

type Slice []error

Slice implements the builtin error interface. This captures a slice of errors.

func (Slice) Err

func (e Slice) Err() error

Err returns the underlying error value for the slice of errors, if the underlying slice contains errors.

func (Slice) Error

func (e Slice) Error() string

Error returns a formatted string of the errors in the slice. Each error will be on a separate line in the returned string.

Jump to

Keyboard shortcuts

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