Documentation ¶
Index ¶
- Variables
- func Code(err error) int32
- func InternalServerError(err error) error
- func IsBadRequest(err error) bool
- func IsInternalServer(err error) bool
- func IsInvalidParam(err error) bool
- func New499Response(code int, msg string, args ...interface{}) error
- func New500Response(code int, msg string, args ...interface{}) error
- func NewResponse(code, statusCode int, msg string, args ...interface{}) error
- func Wrap499Response(err error, msg string, args ...interface{}) error
- func Wrap500Response(err error, msg string, args ...interface{}) error
- func WrapResponse(err error, code, statusCode int, msg string, args ...interface{}) error
- type ResponseError
- type StatusError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrBadRequest = New499Response(9000, "请求发生错误") ErrVerificationFialed = New499Response(9001, "校验失败") ErrInternalServer = New500Response(9002, "服务器内部错误") ErrInvalidParam = New499Response(9003, "请求参数不合法") ErrNotLogin = New499Response(9100, "用户未登录") ErrNoPhoneBound = New499Response(9101, "用户未绑定手机号") ErrNoPermission = New499Response(9102, "无权限操作") ErrActionFailed = New499Response(9103, "操作失败") SaveFailed = New499Response(9104, "保存失败") )
定义错误
Functions ¶
func InternalServerError ¶
func New499Response ¶
func New500Response ¶
func NewResponse ¶
NewResponse 创建响应错误
func Wrap499Response ¶
func Wrap500Response ¶
Types ¶
type ResponseError ¶
type ResponseError struct { Code int // 错误码 Message string // 错误消息 StatusCode int // 响应状态码 ERR error // 响应错误 }
ResponseError 对端错误响应结构
func (*ResponseError) Error ¶
func (r *ResponseError) Error() string
type StatusError ¶
ResponseError 内部服务错误结构
func (*StatusError) Error ¶
func (e *StatusError) Error() string
Click to show internal directories.
Click to hide internal directories.