errors

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: BSD-3-Clause Imports: 3 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 NewError

func NewError(options ...errorOption) *Error

NewError create error

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