xerror

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

* @Date: 2023-07-20 09:34:46 * @LastEditTime: 2023-09-07 16:39:33 * @Description:

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCaptchaWrong     = New(425, "验证码错误")
	ErrBadParameter     = New(426, "请求参数错误")
	ErrInProcess        = New(427, "正在处理中,请稍后再试")
	ErrLoginFailed      = New(401, "登陆失败,请重试")
	ErrTokenNotFound    = New(401, "请先登陆")
	ErrInvalidToken     = New(401, "登陆失效,请重新登陆")
	ErrTokenExpired     = New(401, "登陆过期,请重新登陆")
	ErrUserTokenExpired = New(401, "用户登陆过期,请重新登陆")
	ErrNoPerm           = New(401, "无访问权限")
	ErrInvalidContent   = New(87014, "非法内容")
	ErrIsEmpty          = New(4041, "数据不存在")
	ErrUserIsEmpty      = New(4042, "用户不存在")
	ErrUserStatusWrong  = New(4044, "用户已注销")
	ErrNotFound         = New(404, "资源不存在")
	ErrMethodNotAllow   = New(405, "方法不被允许")
	ErrAppConfigErr     = New(426, "服务配置错误")
	ErrTooManyRequests  = New(429, "请求过于频繁")
	ErrInternalServer   = New(500, "服务器发生错误")
)

定义错误

Functions

func GetCallerInfo added in v0.0.3

func GetCallerInfo(depth int) string

GetCallerInfo 获取调用栈信息

Types

type Error

type Error struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

Error ...

func Errors

func Errors() []*Error

Errors 返回所有 error 列表 按 code 升序 通过 WithMsg 声明的错误码不重复显示

func New

func New(code int, msg string) *Error

New ...

func (*Error) Error

func (e *Error) Error() string

Error ...

func (*Error) WithMsg

func (e *Error) WithMsg(msg string) *Error

WithMsg 自定义错误文案

Jump to

Keyboard shortcuts

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