Documentation
¶
Index ¶
- Variables
- func New400Response(msg string, args ...interface{}) error
- func New500Response(msg string, args ...interface{}) error
- func NewResponse(code, status int, msg string, args ...interface{}) error
- func Wrap400Response(err error, msg string, args ...interface{}) error
- func Wrap500Response(err error, msg string, args ...interface{}) error
- func WrapResponse(err error, code, status int, msg string, args ...interface{}) error
- type ResponseError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( New = errors.New Wrap = errors.Wrap Wrapf = errors.Wrapf WithStack = errors.WithStack WithMessage = errors.WithMessage WithMessagef = errors.WithMessagef )
定义别名
View Source
var ( ErrInvalidToken = NewResponse(40001, 401, "令牌失效") ErrNoPerm = NewResponse(0, 401, "无访问权限") ErrNotFound = NewResponse(0, 404, "资源不存在") ErrMethodNotAllow = NewResponse(0, 405, "方法不被允许") ErrTooManyRequests = NewResponse(0, 429, "请求过于频繁") ErrInternalServer = NewResponse(0, 500, "服务器发生错误") ErrBadRequest = New400Response("请求发生错误") ErrInvalidUser = New400Response("无效的用户") ErrUserDisable = New400Response("用户被禁用,请联系管理员") ErrInvalidParent = New400Response("Not found parent node") ErrNotAllowDeleteWithChild = New400Response("存在子节点,不允许删除") )
定义错误
Functions ¶
func New400Response ¶
New400Response 创建错误码为400的响应错误
func New500Response ¶
New500Response 创建错误码为500的响应错误
func NewResponse ¶
NewResponse 创建响应错误
func Wrap400Response ¶
Wrap400Response 包装错误码为400的响应错误
func Wrap500Response ¶
Wrap500Response 包装错误码为500的响应错误
Types ¶
type ResponseError ¶
type ResponseError struct { Code int // 错误码 Message string // 错误消息 Status int // 响应状态码 ERR error // 响应错误 }
ResponseError 定义响应错误
func (*ResponseError) Error ¶
func (r *ResponseError) Error() string
Click to show internal directories.
Click to hide internal directories.