Documentation
¶
Overview ¶
Package errors provides unified error handling functionality. Defines application error types and predefined error variables, supports error wrapping and context information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Redis related errors ErrRedisConnection = &AppError{ Code: "REDIS_CONN_ERR", Message: "Redis 连接失败", } ErrRedisOperation = &AppError{ Code: "REDIS_OP_ERR", Message: "Redis 操作失败", } ErrRedisLock = &AppError{ Code: "REDIS_LOCK_ERR", Message: "Redis 分布式锁操作失败", } // Configuration related errors ErrConfigLoad = &AppError{ Code: "CONFIG_LOAD_ERR", Message: "配置加载失败", } ErrConfigValidation = &AppError{ Code: "CONFIG_VALIDATION_ERR", Message: "配置验证失败", } ErrConfigParse = &AppError{ Code: "CONFIG_PARSE_ERR", Message: "配置解析失败", } // Application initialization errors ErrAppInit = &AppError{ Code: "APP_INIT_ERR", Message: "应用初始化失败", } // HTTP related errors ErrHTTPRequest = &AppError{ Code: "HTTP_REQ_ERR", Message: "HTTP 请求失败", } ErrHTTPResponse = &AppError{ Code: "HTTP_RESP_ERR", Message: "HTTP 响应处理失败", } // Data related errors ErrDataLoad = &AppError{ Code: "DATA_LOAD_ERR", Message: "数据加载失败", } ErrDataParse = &AppError{ Code: "DATA_PARSE_ERR", Message: "数据解析失败", } // Cache related errors ErrCacheOperation = &AppError{ Code: "CACHE_OP_ERR", Message: "缓存操作失败", } // Parameter validation errors ErrInvalidParameter = &AppError{ Code: "INVALID_PARAM_ERR", Message: "无效的参数", } // Task execution errors ErrTaskExecution = &AppError{ Code: "TASK_EXEC_ERR", Message: "任务执行失败", } )
Predefined error types
Functions ¶
This section is empty.
Types ¶
type AppError ¶
type AppError struct {
Code string // Error code (16 bytes)
Message string // Error message (16 bytes)
Err error // Underlying error (16 bytes interface)
}
AppError application error type, provides unified error handling
func (*AppError) WithLanguage ¶ added in v0.2.0
WithLanguage gets localized error message based on request context If request is nil or language cannot be obtained, returns original message
func (*AppError) WithMessage ¶
WithMessage adds custom message
Click to show internal directories.
Click to hide internal directories.