exception

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: MIT Imports: 2 Imported by: 608

Documentation

Index

Constants

View Source
const (
	TokenExpired = 1000

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

	UnKnownException = 9999
)

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
}

APIException API异常

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 NewPermissionDeny

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

NewPermissionDeny 没有权限访问

func NewTokenExpired

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

NewTokenExpired token过期

func NewUnauthorized

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

NewUnauthorized 未认证

type WithAPIException

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

WithAPIException 携带元信息的异常

func NewAPIException

func NewAPIException(code int, 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