pub enum ForgeError {
Show 17 variants
State {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Event {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Middleware {
message: String,
middleware_name: Option<String>,
source: Option<Box<dyn Error + Send + Sync>>,
},
Extension {
message: String,
extension_name: Option<String>,
source: Option<Box<dyn Error + Send + Sync>>,
},
Transaction {
message: String,
transaction_id: Option<u64>,
source: Option<Box<dyn Error + Send + Sync>>,
},
History {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Config {
message: String,
config_key: Option<String>,
source: Option<Box<dyn Error + Send + Sync>>,
},
Storage {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Cache {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Engine {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Timeout {
operation: String,
timeout_ms: u64,
},
ResourceExhausted {
resource_type: String,
current_usage: Option<usize>,
limit: Option<usize>,
},
Concurrency {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Validation {
message: String,
field: Option<String>,
},
ExternalDependency {
dependency: String,
source: Box<dyn Error + Send + Sync>,
},
Internal {
message: String,
location: Option<String>,
},
Other(Error),
}
Expand description
统一的 Forge 错误类型
这个枚举定义了 ModuForge 核心模块中可能出现的所有错误类型, 提供了结构化的错误处理和更好的错误分类。
Variants§
State
状态管理相关错误
Event
事件系统相关错误
Middleware
中间件相关错误
Extension
扩展和插件相关错误
Transaction
事务处理相关错误
History
历史记录相关错误
Config
配置相关错误
Storage
存储相关错误
Cache
缓存相关错误
Engine
引擎相关错误
Timeout
超时错误
ResourceExhausted
资源不足错误
Concurrency
并发错误
Validation
验证错误
ExternalDependency
外部依赖错误
Internal
内部错误(不应该发生的错误)
Other(Error)
兼容性错误,用于包装其他错误类型
Implementations§
Source§impl ForgeError
impl ForgeError
Sourcepub fn error_code(&self) -> &'static str
pub fn error_code(&self) -> &'static str
获取错误代码,用于程序化处理
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
检查错误是否可重试
Sourcepub fn is_temporary(&self) -> bool
pub fn is_temporary(&self) -> bool
检查错误是否为临时性错误
Trait Implementations§
Source§impl Debug for ForgeError
impl Debug for ForgeError
Source§impl Display for ForgeError
impl Display for ForgeError
Source§impl Error for ForgeError
impl Error for ForgeError
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()
Source§impl From<ConfigValidationError> for ForgeError
impl From<ConfigValidationError> for ForgeError
Source§fn from(err: ConfigValidationError) -> Self
fn from(err: ConfigValidationError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ForgeError
impl !RefUnwindSafe for ForgeError
impl Send for ForgeError
impl Sync for ForgeError
impl Unpin for ForgeError
impl !UnwindSafe for ForgeError
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more