exception

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2020 License: Apache-2.0 Imports: 2 Imported by: 569

Documentation

Index

Constants

View Source
const (
	// AccessTokenIllegal 访问token不合法
	AccessTokenIllegal = 50008
	// RefreshTokenIllegal 刷新token不合法
	RefreshTokenIllegal = 50009
	// OtherClientsLoggedIn 启动端登录
	OtherClientsLoggedIn = 50012
	// AccessTokenExpired token过期
	AccessTokenExpired = 50014
	// RefreshTokenExpired token过期
	RefreshTokenExpired = 50015

	// 1xx - 5xx copy from http status code
	Unauthorized        = http.StatusUnauthorized
	BadRequest          = http.StatusBadRequest
	InternalServerError = http.StatusInternalServerError
	Forbidden           = http.StatusForbidden
	NotFound            = http.StatusNotFound

	UnKnownException = 99999
)
View Source
const (
	// GlobalNamespace 所有服务公用的一些异常
	GlobalNamespace = Namespace("global")
)

Variables

This section is empty.

Functions

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError 判断是否是NotFoundError

Types

type APIException

type APIException interface {
	error
	ErrorCode() int
	Meta() interface{}
	Is(code int) bool
	Namespace() string
	Reason() string
}

APIException API异常

func NewAccessTokenExpired added in v0.1.2

func NewAccessTokenExpired(format string, a ...interface{}) APIException

NewAccessTokenExpired 访问token过期

func NewAccessTokenIllegal added in v0.2.1

func NewAccessTokenIllegal(format string, a ...interface{}) APIException

NewAccessTokenIllegal 访问token过期

func NewBadRequest

func NewBadRequest(format string, a ...interface{}) APIException

NewBadRequest todo

func NewInternalServerError

func NewInternalServerError(format string, a ...interface{}) APIException

NewInternalServerError 500

func NewNotFound

func NewNotFound(format string, a ...interface{}) APIException

NewNotFound todo

func NewOtherClientsLoggedIn added in v0.2.1

func NewOtherClientsLoggedIn(format string, a ...interface{}) APIException

NewOtherClientsLoggedIn 访问token过期

func NewPermissionDeny

func NewPermissionDeny(format string, a ...interface{}) APIException

NewPermissionDeny 没有权限访问

func NewRefreshTokenExpired added in v0.1.2

func NewRefreshTokenExpired(format string, a ...interface{}) APIException

NewRefreshTokenExpired 刷新token过期

func NewRefreshTokenIllegal added in v0.2.1

func NewRefreshTokenIllegal(format string, a ...interface{}) APIException

NewRefreshTokenIllegal 访问token过期

func NewUnauthorized

func NewUnauthorized(format string, a ...interface{}) APIException

NewUnauthorized 未认证

type Namespace added in v0.1.2

type Namespace string

Namespace 异常所属空间

func (Namespace) String added in v0.1.2

func (ns Namespace) String() string

type WithAPIException

type WithAPIException interface {
	APIException
	WithMeta(m interface{}) APIException
}

WithAPIException 携带元信息的异常

func NewAPIException

func NewAPIException(namespace string, code int, reason, format string, a ...interface{}) WithAPIException

NewAPIException 创建一个API异常 用于其他模块自定义异常

Jump to

Keyboard shortcuts

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