Documentation
¶
Index ¶
- 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 ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
BizType string `json:"biz_type"`
Code int `json:"code"`
Msg string `json:"msg"`
Metadata Metadata
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.