Documentation
¶
Index ¶
- func ErrBodyNil() error
- func ErrEmptyRefreshOpts() error
- func ErrIdSessionNotFound() error
- func ErrInputNil() error
- func ErrInvalidRegularFormat(path string) error
- func ErrInvalidType(want string, got any) error
- func ErrKeyNil() error
- func ErrKeyNotFound(key string) error
- func ErrPathClash(pathParam string, path string) error
- func ErrPathNotAllowPathAndRegular(path string) error
- func ErrPathNotAllowWildcardAndPath(path string) error
- func ErrRegularClash(pathParam string, path string) error
- func ErrRegularExpression(err error) error
- func ErrRegularNotAllowRegularAndPath(path string) error
- func ErrRegularNotAllowWildcardAndRegular(path string) error
- func ErrRouterBack() error
- func ErrRouterChildConflict() error
- func ErrRouterConflict(val string) error
- func ErrRouterFront() error
- func ErrRouterGroupBack() error
- func ErrRouterGroupFront() error
- func ErrRouterNotString() error
- func ErrRouterNotSymbolic(path string) error
- func ErrSessionNotFound() error
- func ErrVerificationFailed(err error) error
- func ErrWildcardNotAllowWildcardAndPath(path string) error
- func ErrWildcardNotAllowWildcardAndRegular(path string) error
- type APIError
- func NewAuthError(message string) *APIError
- func NewErrorFromStatus(statusCode int, message string) *APIError
- func NewErrorFromType(errorType ErrorType, message string) *APIError
- func NewInternalError(message string) *APIError
- func NewPermissionError(message string) *APIError
- func NewRateLimitError(message string) *APIError
- func NewResourceNotFoundError(resource string) *APIError
- func NewServiceUnavailableError(message string) *APIError
- func NewTimeoutError(message string) *APIError
- func NewValidationError(message string) *APIError
- func WrapError(err error) *APIError
- type ErrorType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrBodyNil ¶
func ErrBodyNil() error
func ErrEmptyRefreshOpts ¶ added in v0.1.0
func ErrEmptyRefreshOpts() error
func ErrIdSessionNotFound ¶
func ErrIdSessionNotFound() error
func ErrInputNil ¶
func ErrInputNil() error
func ErrInvalidRegularFormat ¶ added in v0.1.18
func ErrInvalidType ¶ added in v0.1.10
func ErrKeyNotFound ¶
func ErrPathClash ¶
func ErrRegularClash ¶
func ErrRegularExpression ¶
func ErrRouterBack ¶ added in v0.0.2
func ErrRouterBack() error
func ErrRouterChildConflict ¶ added in v0.0.10
func ErrRouterChildConflict() error
func ErrRouterConflict ¶ added in v0.0.2
func ErrRouterFront ¶ added in v0.0.2
func ErrRouterFront() error
func ErrRouterGroupBack ¶ added in v0.0.10
func ErrRouterGroupBack() error
func ErrRouterGroupFront ¶ added in v0.0.10
func ErrRouterGroupFront() error
func ErrRouterNotString ¶ added in v0.0.2
func ErrRouterNotString() error
func ErrRouterNotSymbolic ¶ added in v0.0.2
func ErrSessionNotFound ¶
func ErrSessionNotFound() error
func ErrVerificationFailed ¶ added in v0.1.0
Types ¶
type APIError ¶ added in v0.1.21
type APIError struct {
Type ErrorType `json:"type"` // 错误类型
Code int `json:"code"` // HTTP状态码
Message string `json:"message"` // 用户友好的错误信息
Details any `json:"details,omitempty"` // 详细错误信息(可选)
}
APIError 统一API错误结构
func NewErrorFromStatus ¶ added in v0.1.21
从HTTP状态码创建错误
func NewErrorFromType ¶ added in v0.1.21
从错误类型创建错误
func NewInternalError ¶ added in v0.1.21
预定义错误 - 服务器内部错误
func NewPermissionError ¶ added in v0.1.21
预定义错误 - 权限不足
func NewRateLimitError ¶ added in v0.1.21
预定义错误 - 请求频率过高
func NewResourceNotFoundError ¶ added in v0.1.21
预定义错误 - 资源未找到
func NewServiceUnavailableError ¶ added in v0.1.21
预定义错误 - 服务不可用
func NewValidationError ¶ added in v0.1.21
预定义错误 - 输入验证
func (*APIError) WithDetails ¶ added in v0.1.21
WithDetails 添加错误详情
type ErrorType ¶ added in v0.1.21
type ErrorType string
ErrorType 定义标准错误类型
const ( // 错误类型常量 ErrorTypeValidation ErrorType = "VALIDATION_ERROR" // 数据验证错误 ErrorTypeAuth ErrorType = "AUTH_ERROR" // 认证错误 ErrorTypePermission ErrorType = "PERMISSION_ERROR" // 权限错误 ErrorTypeResource ErrorType = "RESOURCE_ERROR" // 资源未找到 ErrorTypeInput ErrorType = "INPUT_ERROR" // 输入错误 ErrorTypeInternal ErrorType = "INTERNAL_ERROR" // 内部服务器错误 ErrorTypeRateLimit ErrorType = "RATE_LIMIT_ERROR" // 限流错误 ErrorTypeTimeout ErrorType = "TIMEOUT_ERROR" // 超时错误 ErrorTypeUnprocessable ErrorType = "UNPROCESSABLE_ERROR" // 无法处理的实体 )
Click to show internal directories.
Click to hide internal directories.