code

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: MIT Imports: 0 Imported by: 0

README

错误码规则

  • 错误码需在 code 包中进行定义。
错误码为 5 位数
1 01 01
服务级错误码 模块级错误码 具体错误码
  • 服务级错误码:1 位数进行表示,比如 1 为系统级错误;2 为普通错误,通常是由用户非法操作引起。
  • 模块级错误码:2 位数进行表示,比如 01 为用户模块;02 为订单模块。
  • 具体的错误码:2 位数进行表示,比如 01 为手机号不合法;02 为验证码输入错误。

Documentation

Index

Constants

View Source
const (
	// 服务级错误码
	ServerError        = 10101
	TooManyRequests    = 10102
	ParamBindError     = 10103
	AuthorizationError = 10104
	CallHTTPError      = 10105
	ResubmitError      = 10106
	ResubmitMsg        = 10107
	HashIdsDecodeError = 10108
	SignatureError     = 10109

	// 业务模块级错误码
	// 用户模块
	IllegalUserName = 20101
	UserCreateError = 20102
	UserUpdateError = 20103
	UserSearchError = 20104

	// 授权调用方
	AuthorizedCreateError    = 20201
	AuthorizedListError      = 20202
	AuthorizedDeleteError    = 20203
	AuthorizedUpdateError    = 20204
	AuthorizedDetailError    = 20205
	AuthorizedCreateAPIError = 20206
	AuthorizedListAPIError   = 20207
	AuthorizedDeleteAPIError = 20208

	// 管理员
	AdminCreateError             = 20301
	AdminListError               = 20302
	AdminDeleteError             = 20303
	AdminUpdateError             = 20304
	AdminResetPasswordError      = 20305
	AdminLoginError              = 20306
	AdminLogOutError             = 20307
	AdminModifyPasswordError     = 20308
	AdminModifyPersonalInfoError = 20309
	AdminMenuListError           = 20310
	AdminMenuCreateError         = 20311

	// 配置
	ConfigEmailError        = 20401
	ConfigSaveError         = 20402
	ConfigRedisConnectError = 20403
	ConfigMySQLConnectError = 20404
	ConfigMySQLInstallError = 20405
	ConfigGoVersionError    = 20406

	// 实用工具箱
	SearchRedisError = 20501
	ClearRedisError  = 20502
	SearchRedisEmpty = 20503
	SearchMySQLError = 20504

	// 菜单栏
	MenuCreateError       = 20601
	MenuUpdateError       = 20602
	MenuListError         = 20603
	MenuDeleteError       = 20604
	MenuDetailError       = 20605
	MenuCreateActionError = 20606
	MenuListActionError   = 20607
	MenuDeleteActionError = 20608
)

Variables

This section is empty.

Functions

func Text added in v1.2.1

func Text(code int) string

Types

type Failure added in v1.2.1

type Failure struct {
	Code    int    `json:"code"`    // 业务码
	Message string `json:"message"` // 描述信息
}

错误时返回结构

Jump to

Keyboard shortcuts

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