Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

errors

v1.1.1
djinn-ci.com/errors

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

14 matches

Top ↑

Package errors implements some utility functions for giving detailed errors.

Functions

Cause

func Cause(err error) error

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

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.

Is

func Is(err, target error) bool

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

MultiError

func MultiError(err ...error) error

MultiError returns a concatenation of the given errors.

New

func New(s string) error

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

Unwrap

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

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.

Error.Error

func (e *Error) Error() string

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

Error.Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying error.

Slice

type Slice []error

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

Slice.Err

func (e Slice) Err() error

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

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.

Dependency graph