Documentation ¶
Overview ¶
Package errorresp 封装了错误定义
Index ¶
- func ErrResp(e error) (httpserver.Responser, error)
- func ErrWrite(e error, w http.ResponseWriter) error
- func IsNotFound(e error) bool
- type APIError
- func (e *APIError) AccessDenied() *APIError
- func (e *APIError) AlreadyExists() *APIError
- func (e *APIError) Code() string
- func (e *APIError) Error() string
- func (e *APIError) ErrorVerificationCode(err error) *APIError
- func (e *APIError) HttpCode() int
- func (e *APIError) InternalError(err error) *APIError
- func (e *APIError) InvalidParameter(err interface{}) *APIError
- func (e *APIError) InvalidState(err string) *APIError
- func (e *APIError) MissingParameter(err string) *APIError
- func (e *APIError) NotFound() *APIError
- func (e *APIError) NotLogin() *APIError
- func (e *APIError) Render(localeResource *i18n.LocaleResource) string
- func (e *APIError) ToResp() httpserver.Responser
- func (e *APIError) Write(w http.ResponseWriter) error
- type MetaMessage
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrResp ¶
func ErrResp(e error) (httpserver.Responser, error)
ErrResp 根据 error 转为一个 http error response.
func IsNotFound ¶
Types ¶
type APIError ¶
type APIError struct {
// contains filtered or unexported fields
}
APIError 接口错误
func (*APIError) ErrorVerificationCode ¶
ErrorVerificationCode 验证码错误
func (*APIError) InternalError ¶
InternalError 异常
func (*APIError) InvalidParameter ¶
InvalidParameter 参数错误
func (*APIError) InvalidState ¶
InvalidState 状态异常
func (*APIError) MissingParameter ¶
MissingParameter 缺少参数
func (*APIError) ToResp ¶
func (e *APIError) ToResp() httpserver.Responser
ToResp 根据 APIError 转为一个 http error response.
type MetaMessage ¶
type Option ¶
type Option func(*APIError)
Option 可选参数
func WithTemplateMessage ¶
WithTemplateMessage 初始化 msg
Click to show internal directories.
Click to hide internal directories.