errors

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetErrorCode

func GetErrorCode(err error) int

GetErrorCode get status code of error

func WithCode

func WithCode(code int) errorOption

WithCode with status code

func WithErr

func WithErr(wrapErr error) errorOption

WithErr with wrap error

func WithMsg

func WithMsg(msg string) errorOption

WithMsg with error msg

func WithMsgf

func WithMsgf(msg string, args ...interface{}) errorOption

WithMsgf with formattable error msg

Types

type Error

type Error struct {
	Code int
	Err  error
	Msg  string
}

Error stacked error with status code [Working with Errors in Go 1.13](https://blog.golang.org/go1.13-errors)

func Err added in v0.0.4

func Err(errCode int, message string, messageArgs ...interface{}) *Error

Err error creation shortcut

func NewError

func NewError(options ...errorOption) *Error

NewError create error

func Wrap added in v0.0.4

func Wrap(wrapErr error, message string, messageArgs ...interface{}) *Error

Wrap wrap error shortcut

func WrapC added in v0.0.4

func WrapC(wrapErr error, errCode int, message string, messageArgs ...interface{}) *Error

WrapC wrap error with code shortcut

func (*Error) As

func (e *Error) As(target error) bool

As implement `As`

func (*Error) Error

func (e *Error) Error() string

No need to print wrapped error, `go` print it automatically

func (*Error) Is

func (e *Error) Is(target error) bool

Is implement `Is`

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap implement `Unwrap`

Jump to

Keyboard shortcuts

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