-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
34 lines (30 loc) · 1.21 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package errors
import (
"github.com/pkg/errors"
)
// 定义别名
var (
New = errors.New
Wrap = errors.Wrap
Wrapf = errors.Wrapf
WithStack = errors.WithStack
WithMessage = errors.WithMessage
WithMessagef = errors.WithMessagef
)
// 定义错误
var (
ErrBadRequest = New400Response("请求发生错误")
ErrInvalidParent = New400Response("无效的父级节点")
ErrNotAllowDeleteWithChild = New400Response("含有子级,不能删除")
ErrNotAllowDelete = New400Response("资源不允许删除")
ErrInvalidUserName = New400Response("无效的用户名")
ErrInvalidPassword = New400Response("无效的密码")
ErrInvalidUser = New400Response("无效的用户")
ErrUserDisable = New400Response("用户被禁用,请联系管理员")
ErrNoPerm = NewResponse(401, 401, "无访问权限")
ErrInvalidToken = NewResponse(9999, 401, "令牌失效")
ErrNotFound = NewResponse(404, 404, "资源不存在")
ErrMethodNotAllow = NewResponse(405, 405, "方法不被允许")
ErrTooManyRequests = NewResponse(429, 429, "请求过于频繁")
ErrInternalServer = NewResponse(500, 500, "服务器发生错误")
)