e

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInternalServerError = Froze("5000000000", "服务器内部错误")
	ErrInvalidParam        = Froze("4000000001", "请求参数不正确")
	ErrNotFound            = Froze("4040000002", "资源不存在")
	ErrNotAllowMethod      = Froze("4050000003", "不允许此方法")
	ErrParseContent        = Froze("5000000004", "解析内容失败")
)

Functions

func AddCode

func AddCode(m map[ErrorCode]struct{}) error

AddCode business code to codeMessageBox

func Code added in v1.2.2

func Code(c *gin.Context, code ErrorCode)

Code gin response with ErrorCode

func Error added in v1.2.2

func Error(c *gin.Context, err error)

Error gin Response with error

Types

type ErrCode

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

ErrCode 规定组成部分为http状态码+5位错误码

func (*ErrCode) Code

func (e *ErrCode) Code() string

func (*ErrCode) Error

func (e *ErrCode) Error() string

func (*ErrCode) MarshalJSON added in v1.2.0

func (e *ErrCode) MarshalJSON() ([]byte, error)

func (*ErrCode) Message

func (e *ErrCode) Message() string

func (*ErrCode) Result added in v1.2.0

func (e *ErrCode) Result() interface{}

func (*ErrCode) StatusCode

func (e *ErrCode) StatusCode() int

func (*ErrCode) UnmarshalJSON added in v1.2.0

func (e *ErrCode) UnmarshalJSON(bytes []byte) error

func (*ErrCode) WithCode added in v1.2.0

func (e *ErrCode) WithCode(code string) ErrorCode

func (*ErrCode) WithMessage

func (e *ErrCode) WithMessage(msg string) ErrorCode

func (*ErrCode) WithResult added in v1.2.0

func (e *ErrCode) WithResult(result interface{}) ErrorCode

func (*ErrCode) WithStatusCode added in v1.2.0

func (e *ErrCode) WithStatusCode(statusCode int) ErrorCode

type ErrorCode

type ErrorCode interface {
	error
	json.Marshaler
	json.Unmarshaler
	StatusCode() int
	Code() string
	Message() string
	Result() interface{}
	WithStatusCode(int) ErrorCode
	WithCode(string) ErrorCode
	WithMessage(string) ErrorCode
	WithResult(interface{}) ErrorCode
}

func From added in v1.2.1

func From(response *http.Response) ErrorCode

func Froze added in v1.2.1

func Froze(code, message string) ErrorCode

type InnerError added in v1.2.0

type InnerError struct {
	Code    string      `json:"code"`
	Message string      `json:"message"`
	Result  interface{} `json:"result"`
}

Jump to

Keyboard shortcuts

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