apierr

package
v0.0.0-...-eea11df Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 1 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorBadRequest      = NewApiError(400, "请求错误")
	ErrorInvalidParam    = NewApiError(4001, "请求参数错误")
	ErrorFrequentRequest = NewApiError(4002, "操作频繁,请在10分钟后再试")

	ErrorUnauthorized = NewApiError(401, "未授权")

	ErrorUserDisabled      = NewApiError(4012, "用户已被禁用")
	ErrorUserNotPermission = NewApiError(4013, "用户无操作权限")
	ErrorUserNotExist      = NewApiError(4014, "用户不存在")
	ErrorUserAlreadyExist  = NewApiError(4015, "用户已存在")
	ErrorUserPasswordError = NewApiError(4016, "用户密码错误")

	ErrorInternalServerError = NewApiError(500, "服务器内部错误")
	ErrorCaptchaVerify       = NewApiError(5001, "验证码错误")
	ErrorSqlQueryError       = NewApiError(5002, "数据库查询错误")
)

Functions

This section is empty.

Types

type ApiError

type ApiError struct {
	Code    int64       `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

ApiError 是一个API错误的结构体

func NewApiError

func NewApiError(code int64, message string) *ApiError

NewApiError 创建一个新的API错误

func (*ApiError) Details

func (e *ApiError) Details() string

func (*ApiError) Error

func (e *ApiError) Error() string

Error 返回错误的消息

func (*ApiError) WrapMessage

func (e *ApiError) WrapMessage(err string) *ApiError

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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