Version: v0.13.0 Latest Latest

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

Go to latest
Published: May 10, 2022 License: Apache-2.0 Imports: 4 Imported by: 12



Package errors provides common utilities for dealing with errors



This section is empty.


This section is empty.


func AggregateConcurrent

func AggregateConcurrent(funcs []func() error) error

AggregateConcurrent runs fns concurrently, returning a NewAggregate if there are > 1 errors

func Errorf

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

Errorf formats according to a format specifier and returns the string as a value that satisfies error. Errorf also records the stack trace at the point it was called.

func Errors

func Errors(err error) []error

Errors returns the deepest Aggregate in a Cause chain

func New

func New(message string) error

New returns an error with the supplied message. New also records the stack trace at the point it was called.

func NewAggregate

func NewAggregate(errlist []error) error

NewAggregate is a compatible wrapper note that while it returns a StackTrace wrapped Aggregate That has been Flattened and Reduced

func NewWithoutStack added in v0.11.0

func NewWithoutStack(message string) error

NewWithoutStack is like new but does NOT wrap with a stack This is useful for exported errors

func StackTrace

func StackTrace(err error) pkgerrors.StackTrace

StackTrace returns the deepest StackTrace in a Cause chain

func UntilErrorConcurrent

func UntilErrorConcurrent(funcs []func() error) error

UntilErrorConcurrent runs all funcs in separate goroutines, returning the first non-nil error returned from funcs, or nil if all funcs return nil

func WithStack

func WithStack(err error) error

WithStack annotates err with a stack trace at the point WithStack was called. If err is nil, WithStack returns nil.

func Wrap

func Wrap(err error, message string) error

Wrap returns an error annotating err with a stack trace at the point Wrap is called, and the supplied message. If err is nil, Wrap returns nil.

func Wrapf

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

Wrapf returns an error annotating err with a stack trace at the point Wrapf is called, and the format specifier. If err is nil, Wrapf returns nil.


type Aggregate added in v0.12.0

type Aggregate interface {
	Errors() []error
	Is(error) bool

Aggregate represents an object that contains multiple errors, but does not necessarily have singular semantic meaning. The aggregate can be used with `errors.Is()` to check for the occurrence of a specific error type. Errors.As() is not supported, because the caller presumably cares about a specific error of potentially multiple that match the given type.

NOTE: this type is originally from Since it is an interface, you can use the implementing types interchangeably

type Causer

type Causer interface {
	// Cause returns the underlying error
	Cause() error

Causer is an interface to error's Cause() wrapping

type StackTracer

type StackTracer interface {
	// StackTrace returns the StackTrace ...
	// TODO: return our own type instead?
	StackTrace() pkgerrors.StackTrace

StackTracer is an interface to error's StackTrace()

Jump to

Keyboard shortcuts

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