error

package
v0.0.0-...-28f24a1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BizErrorMap = map[string]BizErrorStruct{

	"DEFAULT__BAD_REQUEST":    {Code: 400, Message: "请求错误"},
	"DEFAULT__UNAUTHORIZED":   {Code: 401, Message: "需要登录"},
	"DEFAULT__FORBIDDEN":      {Code: 403, Message: "没有权限"},
	"DEFAULT__NOT_FOUND":      {Code: 404, Message: "资源不存在"},
	"DEFAULT__RATE_LIMIT":     {Code: 429, Message: "请求被限流"},
	"DEFAULT__INTERNAL_ERROR": {Code: 500, Message: "内部错误"},

	"TRACKER__INVALID_CLIENT": {Code: 1000, Message: "客户端不合法"},
	"TRACKER__INVALID_PARAMS": {Code: 1001, Message: "请求参数不合法"},

	"STATS__INVALID_PARAMS": {Code: 2000, Message: "请求参数不合法"},
}

Functions

This section is empty.

Types

type BizErrorStruct

type BizErrorStruct struct {
	Code    int
	Message string
}

type CustomError

type CustomError struct {
	Status  int    // HTTP 状态
	Code    int    // 业务错误码
	Message string // 业务错误信息
}

func NewBadRequestError

func NewBadRequestError(errCode string) *CustomError

func NewCustomError

func NewCustomError(status int, code int, message string) *CustomError

func NewForbiddenError

func NewForbiddenError(errCode string) *CustomError

func NewInternalServerError

func NewInternalServerError(errCode string) *CustomError

func NewNotFoundError

func NewNotFoundError(errCode string) *CustomError

func NewUnauthorizedError

func NewUnauthorizedError(errCode string) *CustomError

func (*CustomError) Error

func (e *CustomError) Error() string

func (*CustomError) Serialize

func (e *CustomError) Serialize() map[string]interface{}

Jump to

Keyboard shortcuts

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