pub enum Error {
Show 13 variants
RateLimit {
message: String,
retry_after: String,
raw: String,
},
Business {
code: i64,
message: String,
},
OrderTerminal {
order_id: String,
status: String,
},
ModelNotFound {
model_id: String,
},
Http(HttpError),
Network(NetworkError),
Stream(StreamError),
AgentRunStream {
code: String,
stage: Option<String>,
message: String,
retryable: bool,
},
OAuthTokenEndpoint(OAuthTokenEndpointError),
Json(Error),
Http2(Error),
Io(Error),
Other(String),
}Expand description
SDK 统一错误。变体名对齐 TS 的 7 个错误子类 + Rust 传播用工具变体。
Variants§
RateLimit
下载限流错误(429)。对应 TS RateLimitError。
Business
API 业务层错误(HTTP 200 但 code != 0)。对应 TS BusinessError。
OrderTerminal
订单到达非成功终态。对应 TS OrderTerminalError。
ModelNotFound
模型缓存未命中且刷新后仍未找到。对应 TS ModelNotFoundError。
Http(HttpError)
结构化 HTTP 非 2xx 错误。
Network(NetworkError)
结构化网络层错误。
Stream(StreamError)
流式失败事件。
AgentRunStream
agent run SSE error 事件(throwOnError 为 true 时抛出)。对应 TS AgentRunStreamError。
携带 stage/code/retryable 供调用方判定。
OAuthTokenEndpoint(OAuthTokenEndpointError)
OAuth token 端点(exchange / refresh)结构化错误。对应 TS OAuthTokenEndpointError。
携带 OAuth error 码用于 is_invalid_grant_error 判定。
Json(Error)
Http2(Error)
Io(Error)
Other(String)
其它(含 URL 校验、解析等无专属变体的错误)。
Implementations§
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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<NetworkError> for Error
impl From<NetworkError> for Error
Source§fn from(source: NetworkError) -> Self
fn from(source: NetworkError) -> Self
Converts to this type from the input type.
Source§impl From<OAuthTokenEndpointError> for Error
impl From<OAuthTokenEndpointError> for Error
Source§fn from(source: OAuthTokenEndpointError) -> Self
fn from(source: OAuthTokenEndpointError) -> Self
Converts to this type from the input type.
Source§impl From<SanitizeError> for Error
impl From<SanitizeError> for Error
Source§fn from(e: SanitizeError) -> Self
fn from(e: SanitizeError) -> Self
Converts to this type from the input type.
Source§impl From<StreamError> for Error
impl From<StreamError> for Error
Source§fn from(source: StreamError) -> Self
fn from(source: StreamError) -> Self
Converts to this type from the input type.
Source§impl From<TokenAuthorityError> for Error
impl From<TokenAuthorityError> for Error
Source§fn from(value: TokenAuthorityError) -> Self
fn from(value: TokenAuthorityError) -> Self
Converts to this type from the input type.
Source§impl From<TransportError> for Error
impl From<TransportError> for Error
Source§fn from(value: TransportError) -> Self
fn from(value: TransportError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
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