errno

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

* @Author: reel * @Date: 2023-05-11 22:19:24 * @LastEditors: reel * @LastEditTime: 2024-03-27 04:45:36 * @Description: 定义常用的错误代码

* @Author: reel * @Date: 2023-05-11 22:19:24 * @LastEditors: reel * @LastEditTime: 2023-08-26 21:53:28 * @Description: API 常用状态码

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Errno

type Errno interface {
	WithStack(err error) Errno
	HTTPCode() int

	Message() string
	Stack() error
	ToMap() map[string]interface{}
	ToMapWithData(data interface{}) map[string]interface{}
	ToMapWithError(err error) map[string]interface{}
	WrapData(details interface{}) Errno
	WrapError(err error) Errno
	Notify() Errno
	// contains filtered or unexported methods
}
var (
	ERRNO_OK Errno = New(200, 0, "OK")

	// 系统相关代码
	// 系统内部通用错误代码
	ERRNO_SYSTEM            Errno = New(200, 50000, "系统内部错误")
	ERRNO_TOO_MANY_REQUESTS Errno = New(200, 50001, "请求次数过多,请稍后再试")
	// 系统初始化及授权相关
	ERRNO_INIT        Errno = New(200, 50001, "请先进行项目初始化")
	ERRNO_DISCLAIMERS Errno = New(200, 50002, "请先同意软件服务协议")
	ERRNO_IS_INSTALL  Errno = New(200, 50007, "已完成项目初始化, 请删除配置文件重新更新")

	// 数据库错误相关
	ERRNO_RDB                Errno = New(200, 50100, "数据库通用错误")
	ERRNO_RDB_QUERY          Errno = New(200, 50101, "数据查询错误") //数据查询错误
	ERRNO_RDB_DELETE         Errno = New(200, 50102, "数据删除错误") //数据删除错误
	ERRNO_RDB_CREATE         Errno = New(200, 50103, "数据创建错误") //数据创建错误
	ERRNO_RDB_UPDATE         Errno = New(200, 50104, "数据更新错误") //数据更新错误
	ERRNO_RDB_DUPLICATED_KEY       = New(200, 50105, "重复主键错误") //数据重复错误
	// 缓存错误相关
	ERRNO_CACHE       Errno = New(200, 50201, "缓存错误")
	ERRNO_CACHE_QUERY Errno = New(200, 50201, "缓存查询错误")

	// 业务错误
	// 请求参数
	ERRNO_PARAMS_BIND    Errno = New(200, 10101, "参数绑定错误")
	ERRNO_PARAMS_INVALID Errno = New(200, 10102, "参数校验错误")

	// websocket 错误相关
	ERRNO_WS         Errno = New(200, 10200, "ws 错误")
	ERRNO_WS_REQUEST Errno = New(200, 10201, "创建 ws 连接失败")

	ERRNO_LOGIN_WITH_BROWSER Errno = New(200, 30101, "扫码登录失败")

	// 用户操作错误
	// 请求路径错误
	ERRNO_AUTH             Errno = New(401, 40000, "用户权限错误")
	ERRNO_AUTH_NOT_LOGIN   Errno = New(401, 40001, "用户未登陆")
	ERRNO_AUTH_PERMISSION  Errno = New(401, 40002, "用户无访问权限")
	ERRNO_AUTH_USER_OR_PWD Errno = New(200, 40004, "账号或密码错误")
	ERRNO_AUTH_ELSE_LOGIN  Errno = New(200, 40005, "已在其他地方登陆")
)

func New

func New(httpCode, errno int, msg string) Errno

生成新的 code 暂时不需要调用错误堆栈错误, 需要时再调用

Jump to

Keyboard shortcuts

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