errcode

package
v0.0.0-...-e998ef4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Success      = NewError(0, http.StatusOK, "成功")
	ServerError  = NewError(10000001, http.StatusInternalServerError, "服务内部错误")
	UnknownError = NewError(10000002, http.StatusBadRequest, "未知错误")
)

通用

View Source
var (
	UnauthorizedUserNotExist  = NewError(10001001, http.StatusUnauthorized, "鉴权失败,用户不存在")
	UnauthorizedUserInactive  = NewError(10001002, http.StatusUnauthorized, "鉴权失败,用户不可用")
	UnauthorizedTokenError    = NewError(10001003, http.StatusUnauthorized, "鉴权失败,Token错误")
	UnauthorizedTokenTimeout  = NewError(10001004, http.StatusUnauthorized, "鉴权失败,Token超时")
	UnauthorizedTokenGenerate = NewError(10001005, http.StatusUnauthorized, "鉴权失败,Token生成失败")
	UnauthorizedNoToken       = NewError(10001006, http.StatusUnauthorized, "鉴权失败,未携带Token")
)

认证

View Source
var (
	ServiceNotFound = NewError(10005001, http.StatusBadRequest, "服务不存在")
	ServiceEmpty    = NewError(10005002, http.StatusBadRequest, "无可用服务")
)

服务发现

View Source
var (
	InvalidParams = NewError(10004001, http.StatusBadRequest, "入参错误")
)

参数校验

View Source
var (
	TooManyRequests = NewError(10003001, http.StatusTooManyRequests, "请求过于频繁")
)

限流

Functions

This section is empty.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

func NewError

func NewError(code, httpCode int, msg string) *Error

func (*Error) Code

func (e *Error) Code() int

func (*Error) Details

func (e *Error) Details() []string

func (*Error) Error

func (e *Error) Error() string

func (*Error) Msg

func (e *Error) Msg() string

func (*Error) Msgf

func (e *Error) Msgf(args []interface{}) string

func (*Error) StatusCode

func (e *Error) StatusCode() int

func (*Error) WithDetails

func (e *Error) WithDetails(details ...string) *Error

Jump to

Keyboard shortcuts

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