Documentation ¶
Index ¶
- Variables
- func NewBadRequestError(msg ...string) error
- func NewCodeErr(msg ...string) error
- func NewDataErr(code int, msg ...string) error
- func NewFileErr(msg ...string) error
- func NewForbiddenError(msg ...string) error
- func NewInternalDatabaseError(msg ...string) error
- func NewInternalServerError(msg ...string) error
- func NewMessageError(parent error, code int, msg ...string) (err error)
- func NewNotFoundError(msg ...string) error
- func NewUnauthorizedError(msg ...string) error
- type MessageError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( New = xerrors.New Is = xerrors.Is As = xerrors.As Unwrap = xerrors.Unwrap // 获取内层错误 Errorf = xerrors.Errorf // 获取内层错误 Append = multierror.Append // 获取内层错误 DbMsg = "数据库服务器错误" Casbin = "权限系统错误" Code = "健壮验证错误" ErrForbidden = New("禁止访问") ErrNotFound = New("资源不存在") ErrBadRequest = New("请求无效") ErrInternalServer = New("服务器错误") ErrDatabase = New("数据库请求错误") ErrExistsfail = New("扩展存储错误") ErrCodefail = New("编码错误") )
定义通用错误
Functions ¶
func NewInternalDatabaseError ¶
ErrDatabase 创建数据库错误
func NewInternalServerError ¶
NewInternalServerError 创建服务器错误
func NewMessageError ¶
NewMessageError 创建自定义消息错误
func NewUnauthorizedError ¶
NewUnauthorizedError 创建未授权错误
Types ¶
type MessageError ¶
type MessageError struct {
// contains filtered or unexported fields
}
MessageError 自定义消息错误
func (*MessageError) Error ¶
func (e *MessageError) Error() string
func (e *MessageError) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`,e.Error())), nil }
func (*MessageError) FormatError ¶
func (e *MessageError) FormatError(p xerrors.Printer) (next error)
func (*MessageError) Unwrap ¶
func (e *MessageError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.