errno

package
v0.0.0-...-c1a7e98 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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

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

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

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

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

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

	// ErrUnauthorized 表示请求没有被授权.
	ErrUnauthorized = &Errno{HTTP: 401, Code: "AuthFailure.Unauthorized", Message: "Unauthorized."}

	ErrUserAlreadyExist = &Errno{HTTP: 400, Code: "FailedOperation.UserAlreadyExist", Message: "User already exist."}

	ErrIdempotentTokenExpired = &Errno{HTTP: 400, Code: "IdempotentToken.Expired", Message: "idempotent token is invalid"}

	ErrTemplateCount  = &Errno{HTTP: 400, Code: "TemplateCountFailure.ExceedLimit", Message: "Exceed limit for this template"}
	ErrMobileCount    = &Errno{HTTP: 400, Code: "MobileCountFailure.ExceedLimit", Message: "Exceed limit for this phone"}
	ErrTimestampCount = &Errno{HTTP: 400, Code: "TimestampCountFailure.TooFrequently", Message: "Sent message too frequently"}
)

Functions

func Decode

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

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

Types

type Errno

type Errno struct {
	HTTP    int
	Code    string
	Message string
}

Errno 定义了 monster 使用的错误类型.

func (*Errno) Error

func (err *Errno) Error() string

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

func (*Errno) SetMessage

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

SetMessage 设置 Errno 类型错误中的 Message 字段.

Jump to

Keyboard shortcuts

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