zerror

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: MIT Imports: 7 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Is

func Is(err error, code ...ErrCode) bool

Is returns if err is Error and its code == code

func New

func New(code ErrCode, text string) error

func Panic

func Panic(err error)

Panic if error is not nil, usually used in conjunction with TryCatch

func Reuse added in v1.3.0

func Reuse(err error) error

Reuse the error

func SupText deprecated added in v1.3.0

func SupText(err error, text string) error

Deprecated: please use zerror.With SupText returns the error text

func TryCatch

func TryCatch(fn func() error) (err error)

TryCatch exception capture

func Unwrap

func Unwrap(err error, code ErrCode) (error, bool)

Unwrap returns if err is Error and its code == code

func UnwrapErrors

func UnwrapErrors(err error) (errs []string)

UnwrapErrors Returns the current all error text

func With added in v1.3.2

func With(err error, text string) error

With returns the inner error's text

func Wrap

func Wrap(err error, code ErrCode, text string) error

Wrap wraps err with code

Types

type ErrCode

type ErrCode int32

ErrCode error code type

func UnwrapCode

func UnwrapCode(err error) (ErrCode, bool)

UnwrapCode Returns the current error code

func UnwrapCodes

func UnwrapCodes(err error) (codes []ErrCode)

UnwrapCodes Returns the current all error code

type Error

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

Error wraps err with code

func (*Error) Error

func (e *Error) Error() string

Error returns msg

func (*Error) Format

func (e *Error) Format(s fmt.State, verb rune)

Format formats the frame according to the fmt.Formatter interface

func (*Error) Stack

func (e *Error) Stack() string

Stack returns the stack callers as string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns err inside

Jump to

Keyboard shortcuts

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