errors

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Separator is used to separate nested errors.
	Separator = ":\n\t"
)

Functions

func E

func E(args ...interface{}) error

E creates an error

func Errorf

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

Errorf creates an error from a given format string.

func Is

func Is(kind Kind, err error) bool

Is checks if the error of a given kind.

Types

type Error

type Error struct {
	// Op is the performed operation, usually it is the method name.
	// e.g. Bus.Publish()
	Op Operation
	// Kind of the error such as consumer not found
	// or "Other" if its class is unknown or irrelevant.
	Kind Kind
	// Err is the underlying error that has triggered this one, if any.
	Err error
}

Error is the implementation of the error interface.

func (*Error) Error

func (e *Error) Error() string

type Kind

type Kind uint8

Kind is the error classification.

const (
	// Other is a fallback classification of the error.
	Other Kind = iota
	// Invalid entity is not allowed.
	Invalid
	// Exist item already exists.
	Exist
	// NotFound item is not found.
	NotFound
	// MinLength should be 1 or more.
	MinLength
	// Failure to apply an operation.
	Failure
	// Panic recovery errors.
	Panic
)

func (Kind) String

func (k Kind) String() string

type Operation

type Operation string

Operation that was performed to produce this error.

Jump to

Keyboard shortcuts

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