exception

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 3 Imported by: 6

Documentation

Index

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 未认证
	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) Error

func (e *APIException) Error() string

返回错误信息

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) ToJson

func (e *APIException) ToJson() string

调用这个方法返回结构体的信息

func (*APIException) WithNamespace

func (e *APIException) WithNamespace(ns string) *APIException

Jump to

Keyboard shortcuts

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