Documentation ¶
Index ¶
- func IsNotFound(err error) bool
- type Error
- func BadRequest(format string, args ...any) *Error
- func Exist(format string, args ...any) *Error
- func From(err error) *Error
- func Internal(err error, format string, args ...any) *Error
- func New(bizType string, code int, message string) *Error
- func NotFound(format string, args ...any) *Error
- func Unauthorized(format string, args ...any) *Error
- type Metadata
- type ResCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNotFound ¶ added in v0.1.18
Types ¶
type Error ¶
type Error struct { BizType string `json:"biz_type"` // 业务类型 Code int `json:"code"` // 错误码 Msg string `json:"msg"` // 错误信息 Metadata Metadata // 元数据 IsShow bool // 是否需要展示给用户 Err error // 原始错误 }
func BadRequest ¶
func New ¶
New 创建自定义错误, 通常用于业务并没有err返回, 但是属于业务逻辑错误. 此时需要给前端一个友好提示 eg: New("user-service-Login", 404001, "用户不存在")
func Unauthorized ¶
func (*Error) WithMetadata ¶
Click to show internal directories.
Click to hide internal directories.