Documentation ¶
Index ¶
- Variables
- func New400Response(msg string, args ...interface{}) error
- func New500Response(msg string, args ...interface{}) error
- func NewResponse(code, status int, msg string, args ...interface{}) error
- func Wrap400Response(err error, msg string, args ...interface{}) error
- func Wrap500Response(err error, msg string, args ...interface{}) error
- func WrapResponse(err error, code, status int, msg string, args ...interface{}) error
- type ResponseError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( New = errors.New Wrap = errors.Wrap Wrapf = errors.Wrapf WithStack = errors.WithStack WithMessage = errors.WithMessage WithMessagef = errors.WithMessagef )
Define alias
View Source
var ( ErrInvalidToken = NewResponse(9999, 401, "invalid signature") ErrNoPerm = NewResponse(0, 401, "no permission") ErrNotFound = NewResponse(0, 404, "not found") ErrMethodNotAllow = NewResponse(0, 405, "method not allowed") ErrTooManyRequests = NewResponse(0, 429, "too many requests") ErrInternalServer = NewResponse(0, 500, "internal server error") ErrBadRequest = New400Response("bad request") ErrInvalidParent = New400Response("not found parent node") ErrUserDisable = New400Response("user forbidden") )
Functions ¶
func New400Response ¶
func New500Response ¶
func NewResponse ¶
func Wrap400Response ¶
func Wrap500Response ¶
Types ¶
type ResponseError ¶
type ResponseError struct { Code int // 错误码 Message string // 错误消息 Status int // 响应状态码 ERR error // 响应错误 }
ResponseError 定义响应错误
func UnWrapResponse ¶
func UnWrapResponse(err error) *ResponseError
func (*ResponseError) Error ¶
func (r *ResponseError) Error() string
Click to show internal directories.
Click to hide internal directories.