errors

package
v28.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 1 Imported by: 12

Documentation

Overview

Package errors provides helpers for error creation, avoiding using different packages for errors.

e.g.:

import "github.com/ignite/cli/v28/ignite/pkg/errors"

func main() {
 err1 := errors.New("error new")
 err2 := errors.Errorf("%s: error", foo)
 err3 := errors.Wrap(errFoo, errBar)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target interface{}) bool

As finds the first error in err's chain that matches the type to which target points, and if so, sets the target to its value and returns true. An error matches a type if it is assignable to the target type, or if it has a method As(interface{}) bool such that As(target) returns true. As will panic if target is not a non-nil pointer to a type which implements error or is of interface type.

func Errorf

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

Errorf aliases Newf().

func Is

func Is(err, reference error) bool

Is determines whether one of the causes of the given error or any of its causes is equivalent to some reference error.

func Join

func Join(errs ...error) error

Join returns an error that wraps the given errors. Any nil error values are discarded. Join returns nil if errs contains no non-nil values.

func New

func New(msg string) error

New creates an error with a simple error message. A stack trace is retained.

func Unwrap

func Unwrap(err error) error

Unwrap accesses the direct cause of the error if any, otherwise returns nil.

func WithStack

func WithStack(err error) error

WithStack annotates err with a stack trace at the point WithStack was called.

func Wrap

func Wrap(err error, msg string) error

Wrap wraps an error with a message prefix. A stack trace is retained.

func Wrapf

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

Wrapf wraps an error with a formatted message prefix. A stack trace is also retained. If the format is empty, no prefix is added, but the extra arguments are still processed for reportable strings.

Types

This section is empty.

Jump to

Keyboard shortcuts

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