pub enum LlmError {
Show 14 variants
RateLimited {
retry_after_ms: Option<u64>,
},
ServerOverloaded,
NetworkTimeout {
duration_ms: u64,
},
ConnectionReset,
ServerError {
status: u16,
message: String,
},
InvalidRequest {
message: String,
},
AuthenticationFailed {
message: String,
},
ContentFiltered {
reason: String,
},
ContextLengthExceeded {
max: usize,
requested: usize,
},
ModelNotFound {
model: String,
},
InvalidApiKey,
Unknown {
message: String,
},
StreamParseError {
message: String,
},
IncompleteResponse {
message: String,
},
}Expand description
Errors from LLM providers
Categorized by whether they’re retryable.
Variants§
RateLimited
ServerOverloaded
NetworkTimeout
ConnectionReset
ServerError
InvalidRequest
AuthenticationFailed
ContentFiltered
ContextLengthExceeded
ModelNotFound
InvalidApiKey
Unknown
StreamParseError
IncompleteResponse
Implementations§
Source§impl LlmError
impl LlmError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether this error should trigger a retry
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
Get retry-after hint if available
Sourcepub fn from_http_status(
status: u16,
message: String,
retry_after_ms: Option<u64>,
) -> LlmError
pub fn from_http_status( status: u16, message: String, retry_after_ms: Option<u64>, ) -> LlmError
Create from HTTP status code and message
pub fn from_http_response( status: u16, message: String, headers: &HeaderMap, ) -> LlmError
pub fn parse_retry_after(value: &str) -> Option<u64>
pub fn failure_reason(&self) -> LlmFailureReason
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LlmError
impl<'de> Deserialize<'de> for LlmError
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<LlmError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LlmError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Error for LlmError
impl Error for LlmError
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 Serialize for LlmError
impl Serialize for LlmError
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for LlmError
impl RefUnwindSafe for LlmError
impl Send for LlmError
impl Sync for LlmError
impl Unpin for LlmError
impl UnsafeUnpin for LlmError
impl UnwindSafe 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.