Documentation ¶
Index ¶
- Variables
- func NewBadRequestError(code string, msg ...string) error
- func NewForbiddenError(code string, msg ...string) error
- func NewInternalServerError(code string, msg ...string) error
- func NewMessageError(parent error, code string, msg ...string) error
- func NewNormalError(code string, msg ...string) error
- func NewNotFoundError(code string, msg ...string) error
- func NewUnauthorizedError(code string, msg ...string) error
- func NewValidatorError(err error) error
- func NewValidatorErrorStr(err error) string
- func ValidationErrorToText(e validator.FieldError) string
- type CommonError
- type MessageError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( New = errors.New Wrap = errors.Wrap Wrapf = errors.Wrapf ErrNormal = New("返回code为200,特殊异常") ErrForbidden = New("禁止访问") ErrNotFound = New("资源不存在") ErrBadRequest = New("请求无效") ErrInternalServer = New("服务器错误") ErrImplemented = New("API未实现触发异常") )
定义通用错误
Functions ¶
func NewBadRequestError ¶
NewBadRequestError 创建请求无效错误
func NewForbiddenError ¶
NewForbiddenError 创建资源禁止访问错误
func NewInternalServerError ¶
NewInternalServerError 创建服务器错误
func NewMessageError ¶
NewMessageError 创建自定义消息错误
func NewNormalError ¶
func NewNotFoundError ¶
NewNotFoundError 创建资源不存在错误
func NewUnauthorizedError ¶
NewUnauthorizedError 创建未授权错误
func NewValidatorError ¶
NewValidatorError NewValidatorError
func NewValidatorErrorStr ¶
NewValidatorErrorStr NewValidatorErrorStr
func ValidationErrorToText ¶
func ValidationErrorToText(e validator.FieldError) string
ValidationErrorToText
Types ¶
type CommonError ¶
type CommonError struct {
Errors map[string]interface{} `json:"errors"`
}
CommonError error
func ThrowValidatorError ¶
func ThrowValidatorError(err error) CommonError
ThrowValidatorError ThrowValidatorError
type MessageError ¶
type MessageError struct {
// contains filtered or unexported fields
}
MessageError 自定义消息错误
func (*MessageError) Code ¶
func (m *MessageError) Code() string
func (*MessageError) Error ¶
func (m *MessageError) Error() string
Click to show internal directories.
Click to hide internal directories.