errors

package
v0.21.6 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 7 Imported by: 21

Documentation

Overview

Package errors provides lightweight error handling and classification primitives.

The package provides simple error handling interfaces and functions. It allows to create simple and detailed classified errors.

Index

Constants

This section is empty.

Variables

View Source
var ErrInternal = errors.New("internal error")

ErrInternal is an internal neuron error definition.

Functions

func As added in v0.16.1

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

As executes errors.As function.

func Is added in v0.16.1

func Is(err, target error) bool

Is checks if any of the chained errors is of 'target' type.

func New added in v0.16.0

func New(msg string) error

New creates new error.

func Unwrap added in v0.16.1

func Unwrap(err error) error

Unwrap unwraps provided error.

func Wrap added in v0.16.1

func Wrap(err error, msg string) error

Wrap creates simple ClassError for provided 'c' Class and 'msg' message.

func Wrapf added in v0.16.1

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

Wrapf creates simple formatted ClassError for provided 'c' Class, 'format' and arguments 'args'.

Types

type DetailedError added in v0.16.0

type DetailedError struct {
	// ID is a unique error instance identification number.
	ID uuid.UUID
	// details contains the detailed information.
	Details string
	// message is a message used as a string for the
	// golang error interface implementation.
	Message string
	// Operation is the operation name when the error occurred.
	Operation string
	// contains filtered or unexported fields
}

DetailedError is the class based error definition. Each instance has it's own traceable ID. It contains also a Class variable that might be comparable in logic.

func WrapDet added in v0.16.1

func WrapDet(err error, message string) *DetailedError

WrapDet wraps 'err' error and creates DetailedError with given 'message'.

func WrapDetf added in v0.16.1

func WrapDetf(err error, format string, args ...interface{}) *DetailedError

WrapDetf wraps 'err' error and created DetailedError with formatted message.

func (*DetailedError) Error added in v0.16.0

func (e *DetailedError) Error() string

DetailedError implements error interface.

func (*DetailedError) Unwrap added in v0.16.1

func (e *DetailedError) Unwrap() error

Unwrap unwraps provided error.

func (*DetailedError) WithDetail added in v0.16.0

func (e *DetailedError) WithDetail(detail string) *DetailedError

WithDetail sets error detail.

func (*DetailedError) WithDetailf added in v0.16.0

func (e *DetailedError) WithDetailf(format string, values ...interface{}) *DetailedError

WithDetailf sets error detail.

type MultiError added in v0.16.0

type MultiError []error

MultiError is the slice of errors parsable into a single error.

func (MultiError) Error added in v0.16.0

func (m MultiError) Error() string

Error implements error interface.

func (MultiError) Is added in v0.17.0

func (m MultiError) Is(err error) bool

Is checks if one of the errors is equal to 'err'.

Jump to

Keyboard shortcuts

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