errors

package
v1.13.6 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any

func Any(err error, targets ...error) bool

Any reports whether an error in error's chain matches to any error provided in list.

func ExitErr

func ExitErr(text string, err error, code int)

ExitErr prints error to os.Stderr and call os.Exit with given code.

func ExitMsg

func ExitMsg(text string, code int)

ExitMsg prints message to os.Stderr and call os.Exit with given code.

func Is

func Is(err, target error) bool

Is wraps function errors.Is from stdlib to avoid import it in other places of the magma smart contract (magmasc) package.

Types

type ErrWrapper

type ErrWrapper struct {
	// contains filtered or unexported fields
}

ErrWrapper implements error wrapper interface.

func New

func New(code, text string) *ErrWrapper

New returns constructed error wrapper interface.

func Wrap

func Wrap(code, text string, err error) *ErrWrapper

Wrap wraps given error into a new error with format.

func (*ErrWrapper) Error

func (e *ErrWrapper) Error() string

Error implements error interface.

func (*ErrWrapper) Unwrap

func (e *ErrWrapper) Unwrap() error

Unwrap implements error unwrap interface.

func (*ErrWrapper) Wrap

func (e *ErrWrapper) Wrap(err error) *ErrWrapper

Wrap implements error wrapper interface.

type Error

type Error struct {
	Code string `json:"code,omitempty"`
	Msg  string `json:"msg"`
}

Error type for a new application error.

func NewError added in v1.3.5

func NewError(code string, msg string) *Error

func NewErrorf added in v1.3.5

func NewErrorf(code string, format string, args ...interface{}) *Error

NewErrorf - create a new error with format

func (*Error) Error added in v1.3.5

func (err *Error) Error() string

Jump to

Keyboard shortcuts

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