Documentation ¶
Index ¶
- Constants
- type APIException
- func ApiBadRequest(format string, a ...interface{}) *APIException
- func ApiNotFound(format string, a ...interface{}) *APIException
- func NewAPIException(namespace string, code int, reason, format string, a ...interface{}) *APIException
- func NewAPIException1(code int, reason, format string, a ...interface{}) *APIException
- func NewBadRequest(format string, a ...interface{}) *APIException
- func NewNotFound(format string, a ...interface{}) *APIException
- func NewWebCookisNotFoundnRequest(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 ¶
View Source
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 Unauthorized = http.StatusUnauthorized // BadRequest 请求不合法 BadRequest = http.StatusBadRequest // InternalServerError 服务端内部错误 InternalServerError = http.StatusInternalServerError // Forbidden 无权限 Forbidden = http.StatusForbidden // NotFound 接口未找到 NotFound = http.StatusNotFound // Conflict 资源冲突, 已经存在 Conflict = http.StatusConflict // 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 ApiBadRequest ¶ added in v1.2.8
func ApiBadRequest(format string, a ...interface{}) *APIException
AccessToken is nil (AccessTokenIllegal 访问token不合法)
func ApiNotFound ¶
func ApiNotFound(format string, a ...interface{}) *APIException
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 NewBadRequest ¶
func NewBadRequest(format string, a ...interface{}) *APIException
NewBadRequest todo a 的作用 "Resource not found: %s", "exampleID"
func NewNotFound ¶
func NewNotFound(format string, a ...interface{}) *APIException
NewNotFound todo a 的作用 "Resource not found: %s", "exampleID"
func NewWebCookisNotFoundnRequest ¶
func NewWebCookisNotFoundnRequest(format string, a ...interface{}) *APIException
NewWebCookisNotFoundnRequest todo 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
Click to show internal directories.
Click to hide internal directories.