rerror

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNotFound indicates something was not found.
	ErrNotFound = errors.New("not found")
	// ErrInvalidParams represents the params are invalid, such as empty string.
	ErrInvalidParams = errors.New("invalid params")
	// ErrNotImplemented indicates unimplemented.
	ErrNotImplemented = errors.New("not implemented")
)

Functions

func As

func As(err error, label error) error

As looks up errors whose label is the same as the specific label and return a wrapped error.

func ErrInternalBy

func ErrInternalBy(err error) error

func Is

func Is(err error, label error) bool

Is looks up errors whose label is the same as the specific label and return true if it was found

func UnwrapErrInternal added in v0.3.0

func UnwrapErrInternal(err error) error

func With

func With(label error) func(error) *Error

With returns a new constructor to generate an Error with specific label.

Types

type Error

type Error struct {
	Label    error
	Err      error
	Hidden   bool
	Separate bool
}

Error can hold an error together with label. This is useful for displaying a hierarchical error message cleanly and searching by label later to retrieve a wrapped error. Currently, Go standard error library does not support these use cases. That's why we need our own error type.

func From

func From(label string, err error) *Error

From creates an Error with string label.

func FromSep

func FromSep(label string, err error) *Error

From creates an Error with string label, but separated from wrapped error message when the error is printed.

func Get

func Get(err error) *Error

Get gets Error struct from an error

func (*Error) Error

func (e *Error) Error() string

Error implements error interface.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap implements the interface for errors.Unwrap.

Jump to

Keyboard shortcuts

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