pub enum LlmError {
Config(String),
Auth(String),
RateLimited {
message: String,
retry_after_secs: Option<u64>,
},
Timeout(String),
ModelNotFound(String),
ContentFiltered(String),
TokenLimitExceeded(String),
Provider {
status: u16,
message: String,
},
Connection(String),
Serialization(String),
Transient(String),
Internal(String),
}Expand description
Errors that can occur during LLM operations
Variants§
Config(String)
Provider configuration error
Auth(String)
Authentication failure (invalid API key, expired credentials)
RateLimited
Rate limited by the provider
Fields
Timeout(String)
Request timeout
ModelNotFound(String)
Model not found or not available
ContentFiltered(String)
Content was filtered by safety systems
TokenLimitExceeded(String)
Token limit exceeded (input too long)
Provider
Provider returned an error response
Connection(String)
Network / transport error
Serialization(String)
Serialization / deserialization error
Transient(String)
Transient error (can be retried)
Internal(String)
Internal / unexpected error
Implementations§
Source§impl LlmError
impl LlmError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether this error is retryable
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
Whether this error was rate-limited
Sourcepub fn retry_after_secs(&self) -> Option<u64>
pub fn retry_after_secs(&self) -> Option<u64>
Get retry-after hint if available
Sourcepub fn truncated_message(&self, max_len: usize) -> String
pub fn truncated_message(&self, max_len: usize) -> String
Truncate error message to a maximum length (for logging safety)
Trait Implementations§
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()
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> 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.