Documentation ¶
Index ¶
- Constants
- type APIException
- func NewAPIException(namespace string, code int, reason, format string, a ...interface{}) *APIException
- func NewAPIException1(code int, reason, format string, a ...interface{}) *APIException
- func NewAccessTokenExpired(format string, a ...interface{}) *APIException
- func NewAccessTokenIllegal(format string, a ...interface{}) *APIException
- func NewApiUrlNotFound(format string, a ...interface{}) *APIException
- func NewBadRequest(format string, a ...interface{}) *APIException
- func NewConflict(format string, a ...interface{}) *APIException
- func NewForbidden(format string, a ...interface{}) *APIException
- func NewInternalServerError(format string, a ...interface{}) *APIException
- func NewNotFound(format string, a ...interface{}) *APIException
- func NewOtherClientsLoggedIn(format string, a ...interface{}) *APIException
- func NewOtherIPLoggedIn(format string, a ...interface{}) *APIException
- func NewOtherPlaceLoggedIn(format string, a ...interface{}) *APIException
- func NewPasswordExired(format string, a ...interface{}) *APIException
- func NewRefreshTokenExpired(format string, a ...interface{}) *APIException
- func NewRefreshTokenIllegal(format string, a ...interface{}) *APIException
- func NewSessionTerminated(format string, a ...interface{}) *APIException
- func NewUnKnownException(format string, a ...interface{}) *APIException
- func NewUnauthorized(format string, a ...interface{}) *APIException
- func NewVerifyCodeRequired(format string, a ...interface{}) *APIException
- func NewWebCookisNotFound(format string, a ...interface{}) *APIException
- func (e *APIException) Error() string
- func (e *APIException) ErrorCode() int
- func (e *APIException) GetData() interface{}
- func (e *APIException) GetHttpCode() int
- func (e *APIException) GetMeta() interface{}
- func (e *APIException) GetNamespace() string
- func (e *APIException) GetReason() string
- func (e *APIException) ToJson() string
- func (e *APIException) WithNamespace(ns string) *APIException
Constants ¶
const ( // OtherPlaceLoggedIn 异地登录 OtherPlaceLoggedIn = 50010 // OtherIPLoggedIn 异常IP登录 OtherIPLoggedIn = 50011 // OtherClientsLoggedIn 用户已经通过其他端登录 OtherClientsLoggedIn = 50012 // SessionTerminated 会话中断 SessionTerminated = 50013 // AccessTokenExpired token过期 AccessTokenExpired = 50014 // RefreshTokenExpired token过期 RefreshTokenExpired = 50015 // AccessTokenIllegal 访问token不合法 AccessTokenIllegal = 50016 // RefreshTokenIllegal 刷新token不合法 RefreshTokenIllegal = 50017 // VerifyCodeRequired 需要验证码 VerifyCodeRequired = 50018 // PasswordExired 用户密码过期 PasswordExired = 50019 // cookis is not found for web 浏览器未发现cookis WebCookisNotFound = 50020 //api is not found for web ApiUrlNotFound = 50040 // BadRequest 请求不合法 BadRequest = http.StatusBadRequest Unauthorized = http.StatusUnauthorized // Forbidden 无权限 Forbidden = http.StatusForbidden // NotFound 接口未找到 NotFound = http.StatusNotFound // Conflict 资源冲突, 已经存在 Conflict = http.StatusConflict // InternalServerError 服务端内部错误 InternalServerError = http.StatusInternalServerError // UnKnownException 未知异常 UnKnownException = 99999 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIException ¶
type APIException struct { Namespace string `json:"namespace"` HttpCode int `json:"http_code"` ErrCode int `json:"error_code"` Reason string `json:"reason"` Message string `json:"message"` Meta any `json:"meta"` Data any `json:"data"` }
APIException API异常
func NewAPIException ¶
func NewAPIException(namespace string, code int, reason, format string, a ...interface{}) *APIException
NewAPIException 创建一个API异常 用于其他模块自定义异常
func NewAPIException1 ¶
func NewAPIException1(code int, reason, format string, a ...interface{}) *APIException
NewAPIException 创建一个API异常 用于其他模块自定义异常
func NewAccessTokenExpired ¶
func NewAccessTokenExpired(format string, a ...interface{}) *APIException
AccessTokenExpired 50014 token过期
func NewAccessTokenIllegal ¶
func NewAccessTokenIllegal(format string, a ...interface{}) *APIException
RefreshTokenExpired 50016 访问token不合法
func NewApiUrlNotFound ¶
func NewApiUrlNotFound(format string, a ...interface{}) *APIException
ApiUrlNotFound 50040 api is not found for web
func NewBadRequest ¶
func NewBadRequest(format string, a ...interface{}) *APIException
-----------------------------400 code start --------------------------------------// NewBadRequest 400 a 的作用 "Resource not found: %s", "exampleID"
func NewConflict ¶
func NewConflict(format string, a ...interface{}) *APIException
Conflict 409 资源冲突, 已经存在
func NewInternalServerError ¶
func NewInternalServerError(format string, a ...interface{}) *APIException
NewInternalServerError 500
func NewNotFound ¶
func NewNotFound(format string, a ...interface{}) *APIException
NewNotFound 404 a 的作用 "Resource not found: %s", "exampleID"
func NewOtherClientsLoggedIn ¶
func NewOtherClientsLoggedIn(format string, a ...interface{}) *APIException
OtherClientsLoggedIn 50012 用户已经通过其他端登录
func NewOtherIPLoggedIn ¶
func NewOtherIPLoggedIn(format string, a ...interface{}) *APIException
OtherIPLoggedIn 50011 异常IP登录
func NewOtherPlaceLoggedIn ¶
func NewOtherPlaceLoggedIn(format string, a ...interface{}) *APIException
-----------------------------50000-9999 code start --------------------------------------// OtherPlaceLoggedIn 50010 异地登录
func NewPasswordExired ¶
func NewPasswordExired(format string, a ...interface{}) *APIException
VerifyCodeRequired 50019 用户密码过期
func NewRefreshTokenExpired ¶
func NewRefreshTokenExpired(format string, a ...interface{}) *APIException
RefreshTokenExpired 50015 token过期
func NewRefreshTokenIllegal ¶
func NewRefreshTokenIllegal(format string, a ...interface{}) *APIException
RefreshTokenIllegal 50017 刷新token不合法
func NewSessionTerminated ¶
func NewSessionTerminated(format string, a ...interface{}) *APIException
SessionTerminated 50013 会话中断
func NewUnKnownException ¶
func NewUnKnownException(format string, a ...interface{}) *APIException
UnKnownException 99999 未知异常
func NewUnauthorized ¶
func NewUnauthorized(format string, a ...interface{}) *APIException
Unauthorized 401
func NewVerifyCodeRequired ¶
func NewVerifyCodeRequired(format string, a ...interface{}) *APIException
VerifyCodeRequired 50018 需要验证码
func NewWebCookisNotFound ¶
func NewWebCookisNotFound(format string, a ...interface{}) *APIException
NewWebCookisNotFoundnRequest 50020 cookis is not found for web 浏览器未发现cookis a 的作用 "Resource not found: %s", "exampleID"
func (*APIException) ErrorCode ¶
func (e *APIException) ErrorCode() int
Code exception's code, 如果code不存在返回-1
func (*APIException) GetData ¶
func (e *APIException) GetData() interface{}
func (*APIException) GetHttpCode ¶
func (e *APIException) GetHttpCode() int
Code exception's code, 如果code不存在返回-1
func (*APIException) GetMeta ¶
func (e *APIException) GetMeta() interface{}
func (*APIException) GetNamespace ¶
func (e *APIException) GetNamespace() string
func (*APIException) GetReason ¶
func (e *APIException) GetReason() string
func (*APIException) WithNamespace ¶
func (e *APIException) WithNamespace(ns string) *APIException