Documentation ¶
Index ¶
- Constants
- Variables
- func As(err error, target interface{}) bool
- func ConvertBusinessCode(err error) int
- func Def(t ErrorType, code int32, message string) error
- func ErrCustomData(code int32, message string, args interface{}) error
- func ErrCustomer(message string) error
- func Init(id int32, name string) error
- func Is(err, target error) bool
- func IsBadRequest(err error) bool
- func IsErrorCodeEqual(err, target error) bool
- func IsInternalServer(err error) bool
- func IsInvalidParam(err error) bool
- func Parse(err error) *mErrors.Error
- func RedisIsNil(err error) bool
- func Unwrap(err error) error
- type ErrorType
- type FieldErrors
- type ValidateError
Constants ¶
const ( Success = 0 BadRequest = 9000 VerificationFailed = 9001 InternalServer = 9002 InvalidParam = 9003 NotLogin = 9100 NoPhoneBound = 9101 NoPermission = 9102 ActionFailed = 9103 AccountBanned = 9104 AliPayRequestErr = 9109 UnKnown = 100000 )
Variables ¶
var ( ErrorBadRequest = new499Response(BadRequest, "请求发生错误") ErrorVerificationFailed = new499Response(VerificationFailed, "校验失败") ErrorInternalServer = new500Response(InternalServer, "服务器内部错误") ErrorInvalidParam = new499Response(InvalidParam, "请求参数不合法") ErrorNotLogin = new499Response(NotLogin, "用户未登录") ErrorNoPhoneBound = new499Response(NoPhoneBound, "用户未绑定手机号") ErrorNoPermission = new499Response(NoPermission, "无权限操作") ErrorActionFailed = new499Response(ActionFailed, "操作失败") ErrorBannedFailed = new499Response(AccountBanned, "账号被封禁") ErrorCountryNotFound = new499Response(AccountBanned, "当前国家未知") )
Functions ¶
func As ¶
As finds the first error in err's chain that matches target, and if so, sets target to that error value and returns true.
The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling Unwrap.
An error matches target if the error's concrete value is assignable to the value pointed to by target, or if the error has a method As(interface{}) bool such that As(target) returns true. In the latter case, the As method is responsible for setting target.
As will panic if target is not a non-nil pointer to either a type that implements error, or to any interface type. As returns false if err is nil.
func ConvertBusinessCode ¶
func ErrCustomData ¶
func ErrCustomer ¶
func Is ¶
Is reports whether any error in err's chain matches target.
The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling Unwrap.
An error is considered to match a target if it is equal to that target or if it implements a method Is(error) bool such that Is(target) returns true.
func RedisIsNil ¶
Types ¶
type FieldErrors ¶
type FieldErrors []fieldError
func (*FieldErrors) Copy ¶
func (e *FieldErrors) Copy(item validator.FieldError)
func (*FieldErrors) Error ¶
func (e *FieldErrors) Error() string
type ValidateError ¶
type ValidateError struct { Code int Message string Errors FieldErrors }
Validate Error
func NewValidateError ¶
func NewValidateError(code int, message string, err error) *ValidateError
func (*ValidateError) Error ¶
func (e *ValidateError) Error() string