errc

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Failed  = -1
	Success = 0

	InternalErr = 1

	AuthInternalErr      = 10
	AuthRequired         = 11
	AuthExpired          = 12
	AuthInvalid          = 13
	AuthSignatureInvalid = 14

	ParamRequired = 20
	ParamInvalid  = 21

	NotFound = 404
)

-1--999 system common error code

Variables

View Source
var Messages = map[int]string{
	Failed:               "failed",
	Success:              "ok",
	InternalErr:          "internal error",
	AuthInternalErr:      "auth internal error",
	AuthRequired:         "auth Authorization header required",
	AuthExpired:          "auth expired",
	AuthInvalid:          "auth invalid",
	AuthSignatureInvalid: "auth signature invalid",

	ParamInvalid: "param validator invalid",

	NotFound: "not found",
}

Functions

func MultiError

func MultiError(err ...error) error

func ToInternalError added in v0.1.7

func ToInternalError(err error) error

ToInternalError if not Error, to internal error

func WithStack

func WithStack(err error) error

Types

type Error

type Error struct {
	Code    int      `json:"code" xml:"code"`
	Message string   `json:"message" xml:"message"`
	Stack   []string `json:"-" xml:"-"`
}

func Message

func Message(msg string) Error

func NewError

func NewError(code int, msg string) Error

func (Error) CodeMsg added in v0.1.0

func (e Error) CodeMsg() (int, string)

func (Error) Error

func (e Error) Error() string

func (Error) MultiErr

func (e Error) MultiErr(err error) Error

func (Error) MultiMsg

func (e Error) MultiMsg(msg string) Error

Jump to

Keyboard shortcuts

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