errno

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// OK 代表请求成功.
	OK = &Errno{HTTP: 200, Code: 200, Message: ""}

	// InternalServerError 表示所有未知的服务器端错误.
	InternalServerError = &Errno{HTTP: 500, Code: 1, Message: "Internal server error."}

	// ErrPageNotFound 表示路由不匹配错误.
	ErrPageNotFound = &Errno{HTTP: 404, Code: 404, Message: "Page not found."}

	// ErrRequestEntityTooLarge 表示请求体超过服务器允许的大小.
	ErrRequestEntityTooLarge = &Errno{HTTP: 413, Code: 413, Message: "Request entity too large."}

	// ErrBind 表示参数绑定错误.
	ErrBind = &Errno{HTTP: 400, Code: 1, Message: "Error occurred while binding the request body to the struct."}

	// ErrInvalidParameter 表示所有验证失败的错误.
	ErrInvalidParameter = &Errno{HTTP: 400, Code: 1, Message: "Parameter verification failed."}

	// ErrSignToken 表示签发 JWT Token 时出错.
	ErrSignToken = &Errno{HTTP: 401, Code: 401, Message: "Error occurred while signing the JSON web token."}

	// ErrTokenInvalid 表示 JWT Token 格式错误.
	ErrTokenInvalid = &Errno{HTTP: 401, Code: 401, Message: "Token was invalid."}

	// ErrUnauthorized 表示未授权访问.
	ErrUnauthorized = &Errno{HTTP: 401, Code: 401, Message: "Unauthorized access."}

	// ErrServiceUnavailable 表示服务暂时不可用(如就绪检查发现依赖异常).
	ErrServiceUnavailable = &Errno{HTTP: 503, Code: 503, Message: "Service unavailable."}

	// ErrDBQuery 表示数据库查询错误.
	ErrDBQuery = &Errno{HTTP: 500, Code: 1, Message: "Database query error."}

	// ErrPhoneCodeLimit 表示手机号验证码发送次数限制.
	ErrPhoneCodeLimit = &Errno{HTTP: 429, Code: 1, Message: "Phone code limit."}

	// ErrPhoneCodeTimeLimit 表示手机号验证码发送频率限制.
	ErrPhoneCodeTimeLimit = &Errno{HTTP: 429, Code: 1, Message: "Phone code time limit."}
)
View Source
var (

	// ErrTokenMissing 表示请求头中没有令牌.
	ErrTokenMissing = &Errno{HTTP: 401, Code: 401, Message: "Token missing."}

	// ErrTokenExpired 表示令牌已过期.
	ErrTokenExpired = &Errno{HTTP: 401, Code: 401, Message: "Token expired."}

	// ErrTokenBlacklisted 表示令牌已被吊销(logout 或用户级失效).
	ErrTokenBlacklisted = &Errno{HTTP: 401, Code: 401, Message: "Token has been revoked."}

	// ErrTokenRefreshExpired 表示令牌刷新已过期.
	ErrTokenRefreshExpired = &Errno{HTTP: 401, Code: 401, Message: "Token refresh expired."}

	// ErrTokenRefreshFailed 表示令牌刷新失败.
	ErrTokenRefreshFailed = &Errno{HTTP: 401, Code: 401, Message: "Token refresh failed."}

	// ErrTokenRefreshInvalid 表示令牌刷新无效.
	ErrTokenRefreshInvalid = &Errno{HTTP: 401, Code: 401, Message: "Token refresh invalid."}
)
View Source
var (
	// ErrUserAlreadyExist 代表用户已经存在.
	ErrUserAlreadyExist = &Errno{HTTP: 409, Code: 1, Message: "User already exist."}

	// ErrUserNotFound 表示未找到用户.
	ErrUserNotFound = &Errno{HTTP: 404, Code: 1, Message: "User was not found."}

	// ErrPasswordIncorrect 表示密码不正确.
	ErrPasswordIncorrect = &Errno{HTTP: 401, Code: 1, Message: "Password was incorrect."}

	// ErrUserStatusDisable 表示用户状态禁用.
	ErrUserStatusDisable = &Errno{HTTP: 403, Code: 1, Message: "User status is disabled."}

	// ErrMissingUsernameOrEmail 缺少用户名或邮箱
	ErrMissingUsernameOrEmail = &Errno{HTTP: 400, Code: 1, Message: "Missing username or email."}
)

Functions

func Decode

func Decode(err error) (int, int, string)

Decode 尝试从 err 中解析出业务错误码和错误信息.

Types

type Errno

type Errno struct {
	HTTP    int
	Code    int
	Message string
}

Errno 定义了 AuroraLZDF/go-framework 使用的错误类型.

func (*Errno) Error

func (err *Errno) Error() string

Error 实现 error 接口中的 `Error` 方法.

func (*Errno) SetMessage

func (err *Errno) SetMessage(format string, args ...interface{}) *Errno

SetMessage 返回一个带有自定义 Message 的 Errno 副本,避免修改全局错误码定义.

Jump to

Keyboard shortcuts

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