Documentation
¶
Overview ¶
Package exception 提供异常处理和错误响应功能,支持业务异常和验证异常两种类型。 支持从全局管理器中获取预定义异常,也支持自定义异常创建和抛出。
Index ¶
- func Throw(key string, d ...interface{})
- func VeThrow(key string, d ...interface{})
- type ErrorData
- type Exception
- func (e *Exception) Error() string
- func (e *Exception) ErrorCustom(code int, msg string) response.IResponse
- func (e *Exception) From(r response.IResponse, needToRelease bool) response.IResponse
- func (e *Exception) GetCode() int
- func (e *Exception) GetData() interface{}
- func (e *Exception) GetMsg() string
- func (e *Exception) JsonWithCtx(c providerctx.ICoreContext, status ...int) error
- func (e *Exception) Panic()
- func (e *Exception) Release()
- func (e *Exception) Reset(code int, msg string, data interface{}) response.IResponse
- func (e *Exception) RespData(d ...interface{}) *Exception
- func (e *Exception) SendWithCtx(c providerctx.ICoreContext, status ...int) error
- func (e *Exception) SuccessWithData(data ...interface{}) response.IResponse
- type ExceptionMap
- type ValidateException
- func (e *ValidateException) Error() string
- func (e *ValidateException) ErrorCustom(code int, msg string) response.IResponse
- func (e *ValidateException) From(r response.IResponse, needToRelease bool) response.IResponse
- func (e *ValidateException) GetCode() int
- func (e *ValidateException) GetData() interface{}
- func (e *ValidateException) GetMsg() string
- func (e *ValidateException) JsonWithCtx(c providerctx.ICoreContext, status ...int) error
- func (e *ValidateException) Panic()
- func (e *ValidateException) Release()
- func (e *ValidateException) Reset(code int, msg string, data interface{}) response.IResponse
- func (e *ValidateException) RespData(d ...interface{}) *ValidateException
- func (e *ValidateException) SendWithCtx(c providerctx.ICoreContext, status ...int) error
- func (e *ValidateException) SuccessWithData(data ...interface{}) response.IResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Exception ¶
func GetInternalError ¶
func GetInternalError() *Exception
func GetUnknownError ¶
func GetUnknownError() *Exception
func (*Exception) ErrorCustom ¶
ErrorCustom 错误时的响应,重置code和msg字段
func (*Exception) JsonWithCtx ¶
func (e *Exception) JsonWithCtx(c providerctx.ICoreContext, status ...int) error
JsonWithCtx Exception 使用 ContextProvider 上下文响应 JSON
func (*Exception) SendWithCtx ¶
func (e *Exception) SendWithCtx(c providerctx.ICoreContext, status ...int) error
SendWithCtx 使用 ICoreContext 上下文提供者返回 JSON 响应
func (*Exception) SuccessWithData ¶
SuccessWithData 成功时的响应,重置data字段
type ExceptionMap ¶
type ValidateException ¶
func NewVE ¶
func NewVE(c int, m string, d ...interface{}) *ValidateException
func VeGetInternalError ¶
func VeGetInternalError() *ValidateException
func VeGetNotFoundError ¶
func VeGetNotFoundError() *ValidateException
func VeGetUnknownError ¶
func VeGetUnknownError() *ValidateException
func (*ValidateException) Error ¶
func (e *ValidateException) Error() string
ValidateException Error 实现 error 接口
func (*ValidateException) ErrorCustom ¶
func (e *ValidateException) ErrorCustom(code int, msg string) response.IResponse
ErrorCustom 错误时的响应,重置code和msg字段
func (*ValidateException) GetData ¶
func (e *ValidateException) GetData() interface{}
GetData 获取响应数据
func (*ValidateException) JsonWithCtx ¶
func (e *ValidateException) JsonWithCtx(c providerctx.ICoreContext, status ...int) error
JsonWithCtx ValidateException 使用 ContextProvider 上下文响应 JSON
func (*ValidateException) Panic ¶
func (e *ValidateException) Panic()
Panic ValidateException 直接panic
func (*ValidateException) Release ¶
func (e *ValidateException) Release()
Release 释放 ValidateException 内部RespInfo对象回对象池
func (*ValidateException) Reset ¶
func (e *ValidateException) Reset(code int, msg string, data interface{}) response.IResponse
Reset 重置 ValidateException 字段
func (*ValidateException) RespData ¶
func (e *ValidateException) RespData(d ...interface{}) *ValidateException
RespData 方法用于响应错误,并可添加数据参数
func (*ValidateException) SendWithCtx ¶
func (e *ValidateException) SendWithCtx(c providerctx.ICoreContext, status ...int) error
SendWithCtx 使用 ICoreContext 上下文提供者返回 JSON 响应
func (*ValidateException) SuccessWithData ¶
func (e *ValidateException) SuccessWithData(data ...interface{}) response.IResponse
SuccessWithData 成功时的响应,重置data字段
Click to show internal directories.
Click to hide internal directories.