pub enum ProviderError {
Network {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
retriable: bool,
},
Api {
status: u16,
message: String,
code: Option<String>,
},
Authentication {
message: String,
},
RateLimit {
message: String,
retry_after: Option<Duration>,
},
Timeout {
message: String,
elapsed: Duration,
},
Model {
message: String,
},
Message(String),
}Expand description
Provider 错误(增强版)
§变体说明
Network: 网络错误(可重试)Api: API 错误(根据状态码判断)Authentication: 认证错误(不可重试)RateLimit: 限流错误(可重试,带等待时间)Timeout: 超时错误(可重试)Model: 模型错误Message: 通用错误(向后兼容)
Variants§
Network
网络错误
Api
API 错误
Authentication
认证错误
RateLimit
限流错误
Timeout
超时错误
Model
模型错误
Message(String)
通用错误(向后兼容)
Implementations§
Source§impl ProviderError
impl ProviderError
Sourcepub fn authentication(message: impl Into<String>) -> Self
pub fn authentication(message: impl Into<String>) -> Self
创建认证错误
Sourcepub fn is_retriable(&self) -> bool
pub fn is_retriable(&self) -> bool
判断是否可重试
Sourcepub fn category(&self) -> ErrorCategory
pub fn category(&self) -> ErrorCategory
获取错误类别
Trait Implementations§
Source§impl Debug for ProviderError
impl Debug for ProviderError
Source§impl DiagnosticError for ProviderError
impl DiagnosticError for ProviderError
Source§fn diagnostic(&self) -> ErrorDiagnostic
fn diagnostic(&self) -> ErrorDiagnostic
获取错误的诊断信息
Source§fn is_retriable(&self) -> bool
fn is_retriable(&self) -> bool
判断是否可重试
Source§fn category(&self) -> ErrorCategory
fn category(&self) -> ErrorCategory
获取错误类别
Source§impl Display for ProviderError
impl Display for ProviderError
Source§impl Error for ProviderError
impl Error for ProviderError
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()
Auto Trait Implementations§
impl Freeze for ProviderError
impl !RefUnwindSafe for ProviderError
impl Send for ProviderError
impl Sync for ProviderError
impl Unpin for ProviderError
impl UnsafeUnpin for ProviderError
impl !UnwindSafe for ProviderError
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