errors

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Join

func Join(errs ...error) error

Join is a helper to join multiple errors into a single error.

Example:

err := errors.Join(err1, err2)

Types

type MultiError

type MultiError struct {
	Errors []error
}

MultiError is a collection of errors that implements the error interface.

Example:

errs := &errors.MultiError{}
errs.Append(err1, err2)
if err := errs.ErrorOrNil(); err != nil { ... }

func (*MultiError) Append

func (e *MultiError) Append(errs ...error)

Append adds errors to the collection. Nil errors are ignored.

func (*MultiError) Error

func (e *MultiError) Error() string

Error implements the error interface.

Returns:

A concatenated string of all error messages, separated by semicolons.

func (*MultiError) ErrorOrNil

func (e *MultiError) ErrorOrNil() error

ErrorOrNil returns nil if there are no errors, otherwise returns itself.

func (*MultiError) HasErrors

func (e *MultiError) HasErrors() bool

HasErrors returns true if there are any errors in the collection.

func (*MultiError) Unwrap

func (e *MultiError) Unwrap() []error

Unwrap returns the errors as a slice for errors.Is/As support (Go 1.20+).

Jump to

Keyboard shortcuts

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