pub enum LlmError {
Api(Box<ApiError>),
Connection(Error),
Timeout(Error),
Deserialize {
source: Error,
content: String,
},
InvalidResponse(String),
InvalidArgument(String),
}Expand description
Every error this crate returns.
Variants§
Api(Box<ApiError>)
The server answered with a non-2xx status (APIStatusError and subclasses).
Connection(Error)
No response: DNS, TLS or a dropped connection (APIConnectionError).
Timeout(Error)
The request timed out (APIConnectionTimeoutError).
Deserialize
The response body is not JSON (JSONDeserialize in async-openai).
content holds the start of the body; it is not part of the message, so model
output does not end up in logs by accident.
InvalidResponse(String)
The JSON parsed but is missing expected fields.
InvalidArgument(String)
Client-side validation before the request is sent (InvalidArgument in async-openai).
Implementations§
Source§impl LlmError
impl LlmError
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
Request ID of the response, if the server sent one.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Same retry rules as the SDKs: 408, 409, 429, >= 500, connection errors and timeouts.
Trait Implementations§
Source§impl Error for LlmError
impl Error for LlmError
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 !RefUnwindSafe for LlmError
impl !UnwindSafe for LlmError
impl Freeze for LlmError
impl Send for LlmError
impl Sync for LlmError
impl Unpin for LlmError
impl UnsafeUnpin for LlmError
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