pub enum UvsReason {
ValidationError(String),
BusinessError(String),
NotFoundError(String),
PermissionError(String),
DataError(String, Option<usize>),
SystemError(String),
NetworkError(String),
ResourceError(String),
TimeoutError(String),
ConfigError(ConfErrReason),
ExternalError(String),
LogicError(String),
}
Expand description
Universal error reason classification with clear hierarchical structure 统一错误原因分类 - 采用清晰的分层结构
§Error Code Ranges
- 100-199: Business Layer Errors (业务层错误)
- 200-299: Infrastructure Layer Errors (基础设施层错误)
- 300-399: Configuration & External Layer Errors (配置和外部层错误)
§Classification Principles
- Business Layer: User-facing errors that are expected in normal operation
- Infrastructure Layer: System-level failures that should be rare
- Configuration & External: Environment and third-party service issues
Variants§
ValidationError(String)
Input validation errors (格式错误、参数校验失败等)
BusinessError(String)
Business logic rule violations (业务规则违反、状态冲突等)
NotFoundError(String)
Resource not found (查询的资源不存在)
PermissionError(String)
Permission and authorization errors (权限不足、认证失败)
DataError(String, Option<usize>)
Database and data processing errors (数据库操作、数据格式错误)
SystemError(String)
File system and OS-level errors (文件系统、操作系统错误)
NetworkError(String)
Network connectivity and protocol errors (网络连接、HTTP请求错误)
ResourceError(String)
Resource exhaustion (内存不足、磁盘空间不足等)
TimeoutError(String)
Operation timeouts (操作超时)
ConfigError(ConfErrReason)
Configuration-related errors (配置相关错误)
ExternalError(String)
Third-party service errors (第三方服务错误)
LogicError(String)
Third-party service errors (第三方服务错误)
Implementations§
Source§impl UvsReason
impl UvsReason
pub fn core_conf<S: Into<String>>(msg: S) -> Self
pub fn feature_conf<S: Into<String>>(msg: S) -> Self
pub fn dynamic_conf<S: Into<String>>(msg: S) -> Self
pub fn validation_error<S: Into<String>>(msg: S) -> Self
pub fn business_error<S: Into<String>>(msg: S) -> Self
pub fn not_found_error<S: Into<String>>(msg: S) -> Self
pub fn permission_error<S: Into<String>>(msg: S) -> Self
pub fn data_error<S: Into<String>>(msg: S, pos: Option<usize>) -> Self
pub fn system_error<S: Into<String>>(msg: S) -> Self
pub fn network_error<S: Into<String>>(msg: S) -> Self
pub fn resource_error<S: Into<String>>(msg: S) -> Self
pub fn timeout_error<S: Into<String>>(msg: S) -> Self
pub fn external_error<S: Into<String>>(msg: S) -> Self
pub fn logic_error<S: Into<String>>(msg: S) -> Self
Source§impl UvsReason
impl UvsReason
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if this error is retryable 检查错误是否可重试
Sourcepub fn is_high_severity(&self) -> bool
pub fn is_high_severity(&self) -> bool
Check if this error should be logged with high severity 检查错误是否需要高优先级记录
Sourcepub fn category_name(&self) -> &'static str
pub fn category_name(&self) -> &'static str
Get error category name for monitoring and metrics 获取错误类别名称用于监控和指标
Trait Implementations§
Source§impl Error for UvsReason
impl Error for UvsReason
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
impl StructuralPartialEq for UvsReason
Auto Trait Implementations§
impl Freeze for UvsReason
impl RefUnwindSafe for UvsReason
impl Send for UvsReason
impl Sync for UvsReason
impl Unpin for UvsReason
impl UnwindSafe for UvsReason
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more