pub enum LlmError {
Show 13 variants
ApiError(String),
RateLimited(String),
InvalidRequest(String),
AuthError(String),
TokenLimitExceeded {
max: usize,
got: usize,
},
ModelNotFound(String),
NetworkError(String),
SerializationError(Error),
ConfigError(String),
ProviderError(String),
Timeout,
NotSupported(String),
Unknown(String),
}Expand description
Errors that can occur in LLM operations.
Variants§
ApiError(String)
API error from the provider.
RateLimited(String)
Rate limit exceeded.
InvalidRequest(String)
Invalid request parameters.
AuthError(String)
Authentication error.
TokenLimitExceeded
Token limit exceeded.
ModelNotFound(String)
Model not found.
NetworkError(String)
Network error.
SerializationError(Error)
Serialization error.
ConfigError(String)
Configuration error.
ProviderError(String)
Provider-specific error.
Timeout
Timeout error.
NotSupported(String)
Feature not supported.
Unknown(String)
Unknown error.
Implementations§
Source§impl LlmError
impl LlmError
Sourcepub fn retry_strategy(&self) -> RetryStrategy
pub fn retry_strategy(&self) -> RetryStrategy
Get the appropriate retry strategy for this error.
§Returns
ExponentialBackofffor transient network/server errorsWaitAndRetryfor rate limitingReduceContextfor token limit errorsNoRetryfor permanent errors (auth, invalid request, etc.)
§Example
use edgequake_llm::{LlmError, RetryStrategy};
let error = LlmError::NetworkError("connection failed".to_string());
let strategy = error.retry_strategy();
assert!(strategy.should_retry());Sourcepub fn user_description(&self) -> String
pub fn user_description(&self) -> String
Get a user-friendly description of the error with suggested action.
§Example
use edgequake_llm::LlmError;
let error = LlmError::AuthError("invalid key".to_string());
assert!(error.user_description().contains("API key"));Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Check if this error is recoverable (can be retried).
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()
Source§impl From<OpenAIError> for LlmError
impl From<OpenAIError> for LlmError
Source§fn from(err: OpenAIError) -> Self
fn from(err: OpenAIError) -> Self
Converts to this type from the input type.
Source§impl From<VsCodeError> for LlmError
impl From<VsCodeError> for LlmError
Source§fn from(err: VsCodeError) -> Self
fn from(err: VsCodeError) -> Self
Converts to this type from the input type.
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.