Documentation ¶
Index ¶
- func As(err error, target interface{}) bool
- func Code(err error) int32
- func Is(err, target error) bool
- func IsBadRequest(err error) bool
- func IsForbidden(err error) bool
- func IsHTTPError(err error) bool
- func IsInternalServerError(err error) bool
- func IsNotFound(err error) bool
- func IsUnauthorized(err error) bool
- func Reason(err error) string
- func Unwrap(err error) error
- type HTTPError
- func BadRequest(reason, message string) *HTTPError
- func Forbidden(reason, message string) *HTTPError
- func InternalServerError(reason, message string) *HTTPError
- func New(code int32, reason, message string) *HTTPError
- func Newf(code int32, reason, format string, args ...any) *HTTPError
- func NotFound(reason, message string) *HTTPError
- func Unauthorized(reason, message string) *HTTPError
- func (e *HTTPError) Cause() error
- func (e *HTTPError) Clone() *HTTPError
- func (e *HTTPError) Error() string
- func (e *HTTPError) GetMessage() string
- func (e *HTTPError) GetMetadata() map[string]string
- func (e *HTTPError) GetReason() string
- func (e *HTTPError) Is(target error) bool
- func (e *HTTPError) StatusCode() int32
- func (e *HTTPError) Unwrap() error
- func (e *HTTPError) WithCause(cause error) *HTTPError
- func (e *HTTPError) WithMetadata(metadata map[string]string) *HTTPError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsInternalServerError ¶
IsInternalServerError 判断错误是否为 InternalServerError
Types ¶
type HTTPError ¶
type HTTPError struct { Code int32 `json:"code,omitempty"` // HTTP 状态码 Reason string `json:"reason,omitempty"` // 自定义错误码 Message string `json:"message,omitempty"` // 错误信息 Metadata map[string]string `json:"metadata,omitempty"` // 附加信息 // contains filtered or unexported fields }
HTTPError 表示一个 HTTP 错误
func BadRequest ¶
BadRequest 创建一个新的 BadRequest 错误
func InternalServerError ¶
InternalServerError 创建一个新的 InternalServerError 错误
func Unauthorized ¶
Unauthorized 创建一个新的 Unauthorized 错误
func (*HTTPError) GetMessage ¶ added in v0.1.1
GetMessage 获取错误信息
func (*HTTPError) GetMetadata ¶ added in v0.1.1
GetMetadata 获取附加信息
Click to show internal directories.
Click to hide internal directories.