error

package
v0.3.12 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 5 Imported by: 40

Documentation

Index

Constants

View Source
const (
	ServerError   = 500
	BusinessError = 5001
	Success       = 200
)

Variables

This section is empty.

Functions

func CodeToMessage

func CodeToMessage(code int) string

func InjectCodeMessage

func InjectCodeMessage(m map[int]string)

Types

type Error

type Error interface {
	Error() string
	ErrorType() int
	Code() int
	Msg() string
	HttpCode() int
	String() string
	Encode() error
}

func DecodeError added in v0.1.9

func DecodeError(err error) Error

func NewBusinessError

func NewBusinessError(code int, msg string, err error) Error

func NewError

func NewError(code int, msg string, err error, errType int) Error

func NewMsgError added in v0.3.9

func NewMsgError(code, httpCode, errType int, msg string) Error

func NewRawError added in v0.2.1

func NewRawError(code int, msg string, err error, errType int, httpCode int) Error

func NewServerError

func NewServerError(code int, msg string, err error) Error

func NewStandardBusinessError added in v0.2.6

func NewStandardBusinessError(msg string) Error

func NewStandardServerError added in v0.2.3

func NewStandardServerError(err error) Error

type ErrorImpl added in v0.2.1

type ErrorImpl struct {
	ErrType     int    `json:"err_type"`
	ErrCode     int    `json:"err_code"`
	ErrMsg      string `json:"err_msg"`       // User readable information
	ErrDetail   string `json:"err_detail"`    // Developer debugging information
	ErrHttpCode int    `json:"err_http_code"` // Http status code
}

func (*ErrorImpl) Code added in v0.2.1

func (e *ErrorImpl) Code() int

func (*ErrorImpl) Encode added in v0.2.1

func (e *ErrorImpl) Encode() error

func (*ErrorImpl) Error added in v0.2.1

func (e *ErrorImpl) Error() string

func (*ErrorImpl) ErrorType added in v0.2.1

func (e *ErrorImpl) ErrorType() int

func (*ErrorImpl) HttpCode added in v0.2.1

func (e *ErrorImpl) HttpCode() int

func (*ErrorImpl) Msg added in v0.2.1

func (e *ErrorImpl) Msg() string

func (*ErrorImpl) SetErrCode added in v0.2.1

func (e *ErrorImpl) SetErrCode(code int)

func (*ErrorImpl) SetErrDetail added in v0.2.1

func (e *ErrorImpl) SetErrDetail(detail string)

func (*ErrorImpl) SetErrMsg added in v0.2.1

func (e *ErrorImpl) SetErrMsg(msg string)

func (*ErrorImpl) SetErrType added in v0.2.1

func (e *ErrorImpl) SetErrType(errType int)

func (*ErrorImpl) SetHttpCode added in v0.2.1

func (e *ErrorImpl) SetHttpCode(code int)

func (*ErrorImpl) String added in v0.2.1

func (e *ErrorImpl) String() string

Jump to

Keyboard shortcuts

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