errs

package
v0.1.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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 ErrInvalidRegularFormat(path string) error

func ErrInvalidType added in v0.1.10

func ErrInvalidType(want string, got any) error

func ErrKeyNil

func ErrKeyNil() error

func ErrKeyNotFound

func ErrKeyNotFound(key string) error

func ErrPathClash

func ErrPathClash(pathParam string, path string) error

func ErrPathNotAllowPathAndRegular

func ErrPathNotAllowPathAndRegular(path string) error

func ErrPathNotAllowWildcardAndPath

func ErrPathNotAllowWildcardAndPath(path string) error

func ErrRegularClash

func ErrRegularClash(pathParam string, path string) error

func ErrRegularExpression

func ErrRegularExpression(err error) error

func ErrRegularNotAllowRegularAndPath

func ErrRegularNotAllowRegularAndPath(path string) error

func ErrRegularNotAllowWildcardAndRegular

func ErrRegularNotAllowWildcardAndRegular(path string) error

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 ErrRouterConflict(val string) error

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 ErrRouterNotSymbolic(path string) error

func ErrSessionNotFound

func ErrSessionNotFound() error

func ErrVerificationFailed added in v0.1.0

func ErrVerificationFailed(err error) error

func ErrWildcardNotAllowWildcardAndPath

func ErrWildcardNotAllowWildcardAndPath(path string) error

func ErrWildcardNotAllowWildcardAndRegular

func ErrWildcardNotAllowWildcardAndRegular(path string) error

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 NewAuthError added in v0.1.21

func NewAuthError(message string) *APIError

预定义错误 - 认证失败

func NewErrorFromStatus added in v0.1.21

func NewErrorFromStatus(statusCode int, message string) *APIError

从HTTP状态码创建错误

func NewErrorFromType added in v0.1.21

func NewErrorFromType(errorType ErrorType, message string) *APIError

从错误类型创建错误

func NewInternalError added in v0.1.21

func NewInternalError(message string) *APIError

预定义错误 - 服务器内部错误

func NewPermissionError added in v0.1.21

func NewPermissionError(message string) *APIError

预定义错误 - 权限不足

func NewRateLimitError added in v0.1.21

func NewRateLimitError(message string) *APIError

预定义错误 - 请求频率过高

func NewResourceNotFoundError added in v0.1.21

func NewResourceNotFoundError(resource string) *APIError

预定义错误 - 资源未找到

func NewServiceUnavailableError added in v0.1.21

func NewServiceUnavailableError(message string) *APIError

预定义错误 - 服务不可用

func NewTimeoutError added in v0.1.21

func NewTimeoutError(message string) *APIError

预定义错误 - 请求超时

func NewValidationError added in v0.1.21

func NewValidationError(message string) *APIError

预定义错误 - 输入验证

func WrapError added in v0.1.21

func WrapError(err error) *APIError

从标准错误创建API错误

func (*APIError) Error added in v0.1.21

func (e *APIError) Error() string

Error 实现error接口

func (*APIError) ToJSON added in v0.1.21

func (e *APIError) ToJSON() []byte

ToJSON 将APIError转换为JSON格式

func (*APIError) WithDetails added in v0.1.21

func (e *APIError) WithDetails(details any) *APIError

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"      // 内部服务器错误
	ErrorTypeUnavailable   ErrorType = "UNAVAILABLE_ERROR"   // 服务不可用
	ErrorTypeRateLimit     ErrorType = "RATE_LIMIT_ERROR"    // 限流错误
	ErrorTypeTimeout       ErrorType = "TIMEOUT_ERROR"       // 超时错误
	ErrorTypeUnprocessable ErrorType = "UNPROCESSABLE_ERROR" // 无法处理的实体
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL