pub enum TranslationError {
ServiceError(String),
NetworkError(String),
ParseError(String),
ConfigError(String),
CacheError(String),
IoError(String),
InternalError(String),
FeatureNotEnabled(String),
UnsupportedLanguage(String),
ApiLimitError(String),
TimeoutError(String),
}Expand description
翻译错误枚举
涵盖了翻译过程中可能出现的各种错误情况,每种错误都包含详细的上下文信息
Variants§
ServiceError(String)
翻译服务错误
NetworkError(String)
网络连接错误
ParseError(String)
HTML解析错误
ConfigError(String)
配置错误
CacheError(String)
缓存操作错误
IoError(String)
文件IO错误
InternalError(String)
内部错误
FeatureNotEnabled(String)
特性未启用
UnsupportedLanguage(String)
不支持的语言
ApiLimitError(String)
API限制错误
TimeoutError(String)
超时错误
Implementations§
Source§impl TranslationError
impl TranslationError
Sourcepub fn service_error(msg: impl Into<String>) -> Self
pub fn service_error(msg: impl Into<String>) -> Self
创建服务错误
Sourcepub fn network_error(msg: impl Into<String>) -> Self
pub fn network_error(msg: impl Into<String>) -> Self
创建网络错误
Sourcepub fn parse_error(msg: impl Into<String>) -> Self
pub fn parse_error(msg: impl Into<String>) -> Self
创建解析错误
Sourcepub fn config_error(msg: impl Into<String>) -> Self
pub fn config_error(msg: impl Into<String>) -> Self
创建配置错误
Sourcepub fn cache_error(msg: impl Into<String>) -> Self
pub fn cache_error(msg: impl Into<String>) -> Self
创建缓存错误
Sourcepub fn internal_error(msg: impl Into<String>) -> Self
pub fn internal_error(msg: impl Into<String>) -> Self
创建内部错误
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
错误是否可重试
Sourcepub fn category(&self) -> ErrorCategory
pub fn category(&self) -> ErrorCategory
获取错误类别
Sourcepub fn severity(&self) -> ErrorSeverity
pub fn severity(&self) -> ErrorSeverity
获取错误严重程度
Trait Implementations§
Source§impl Clone for TranslationError
impl Clone for TranslationError
Source§fn clone(&self) -> TranslationError
fn clone(&self) -> TranslationError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TranslationError
impl Debug for TranslationError
Source§impl Display for TranslationError
impl Display for TranslationError
Source§impl Error for TranslationError
impl Error for TranslationError
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()
Source§impl From<Error> for TranslationError
impl From<Error> for TranslationError
Source§impl From<Error> for TranslationError
impl From<Error> for TranslationError
Source§impl From<Error> for TranslationError
impl From<Error> for TranslationError
Auto Trait Implementations§
impl Freeze for TranslationError
impl RefUnwindSafe for TranslationError
impl Send for TranslationError
impl Sync for TranslationError
impl Unpin for TranslationError
impl UnsafeUnpin for TranslationError
impl UnwindSafe for TranslationError
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.