Documentation ¶
Index ¶
- Variables
- func GetCode(err error) int
- func GetErrMsg(err error) string
- type Err
- func (w *Err) Error() string
- func (w *Err) GetCode() int
- func (w *Err) GetFullMsg() string
- func (w *Err) Is(target error) bool
- func (w *Err) New() *Err
- func (w *Err) Unwrap() error
- func (w *Err) WithCode(code ErrCode) *Err
- func (w *Err) WithError(err error) *Err
- func (w *Err) WithMsg(msg string) *Err
- func (w *Err) WithMsgf(format string, args ...interface{}) *Err
- type ErrCode
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NormalError = &Err{Code: ErrorNormal, Message: "业务错误"} // 2100 ParamError = &Err{Code: ErrorParam, Message: "参数错误"} // 4000 NoPermissionError = &Err{Code: ErrorNoPermission, Message: "无权限"} // 4001 InternalError = &Err{Code: ErrorInternal, Message: "内部错误"} // 5000 InvalidTokenError = &Err{Code: ErrorInvalidToken, Message: "凭证无效"} // invalidToken NotExistsError = &Err{Code: ErrorNotExists, Message: "未找到"} // not found )
定义通用错误 pkg errors cause error
Functions ¶
Types ¶
type Err ¶
func NewInternal ¶
func NewInternal() *Err
func NewInvalidToken ¶
func NewInvalidToken() *Err
func NewNoPermission ¶
func NewNoPermission() *Err
func NewNotExistsError ¶
func NewNotExistsError() *Err
func NewParamError ¶
func NewParamError() *Err
func ToErrOrNil ¶
func (*Err) GetFullMsg ¶
Click to show internal directories.
Click to hide internal directories.