pub enum Error {
Show 14 variants
InvalidConfig(String),
MissingRequiredField {
field: &'static str,
},
MissingCredentials,
Api(ApiError),
Connection(ConnectionError),
Timeout,
Stream(StreamError),
WebSocket(WebSocketError),
Serialization(SerializationError),
LengthFinishReason(LengthFinishReasonError),
ContentFilterFinishReason(ContentFilterFinishReasonError),
WebhookVerification(WebhookVerificationError),
ProviderCompatibility(ProviderCompatibilityError),
Cancelled,
}Expand description
SDK 对外暴露的统一错误类型。
Variants§
InvalidConfig(String)
表示客户端配置无效。
MissingRequiredField
表示请求缺少必填字段。
MissingCredentials
表示缺少请求所需的凭证。
Api(ApiError)
表示接口返回了业务错误。
Connection(ConnectionError)
表示底层网络连接相关错误。
Timeout
表示请求执行超时。
Stream(StreamError)
表示流式解析相关错误。
WebSocket(WebSocketError)
表示 WebSocket 错误。
Serialization(SerializationError)
表示序列化或反序列化失败。
LengthFinishReason(LengthFinishReasonError)
表示模型因长度截断而无法完成结构化语义。
ContentFilterFinishReason(ContentFilterFinishReasonError)
表示模型因内容过滤而无法完成结构化语义。
WebhookVerification(WebhookVerificationError)
表示 Webhook 校验失败。
ProviderCompatibility(ProviderCompatibilityError)
表示当前 Provider 的兼容性校验失败。
Cancelled
表示请求被主动取消。
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<ConnectionError> for Error
impl From<ConnectionError> for Error
Source§fn from(source: ConnectionError) -> Self
fn from(source: ConnectionError) -> Self
Converts to this type from the input type.
Source§impl From<ContentFilterFinishReasonError> for Error
impl From<ContentFilterFinishReasonError> for Error
Source§fn from(source: ContentFilterFinishReasonError) -> Self
fn from(source: ContentFilterFinishReasonError) -> Self
Converts to this type from the input type.
Source§impl From<LengthFinishReasonError> for Error
impl From<LengthFinishReasonError> for Error
Source§fn from(source: LengthFinishReasonError) -> Self
fn from(source: LengthFinishReasonError) -> Self
Converts to this type from the input type.
Source§impl From<ProviderCompatibilityError> for Error
impl From<ProviderCompatibilityError> for Error
Source§fn from(source: ProviderCompatibilityError) -> Self
fn from(source: ProviderCompatibilityError) -> Self
Converts to this type from the input type.
Source§impl From<SerializationError> for Error
impl From<SerializationError> for Error
Source§fn from(source: SerializationError) -> Self
fn from(source: SerializationError) -> 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<WebSocketError> for Error
impl From<WebSocketError> for Error
Source§fn from(source: WebSocketError) -> Self
fn from(source: WebSocketError) -> Self
Converts to this type from the input type.
Source§impl From<WebhookVerificationError> for Error
impl From<WebhookVerificationError> for Error
Source§fn from(source: WebhookVerificationError) -> Self
fn from(source: WebhookVerificationError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe 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
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.