pub enum LlmError {
Show 26 variants
HttpError(String),
JsonError(String),
ParseError(String),
InvalidInput(String),
IoError(String),
NotFound(String),
MissingApiKey(String),
InvalidParameter(String),
ApiError {
code: u16,
message: String,
details: Option<Value>,
},
AuthenticationError(String),
RateLimitError(String),
QuotaExceededError(String),
ModelNotSupported(String),
StreamError(String),
TimeoutError(String),
ConnectionError(String),
ProviderError {
provider: String,
message: String,
error_code: Option<String>,
},
ConfigurationError(String),
InternalError(String),
UnsupportedOperation(String),
ProcessingError(String),
ToolCallError(String),
ToolValidationError(String),
UnsupportedToolType(String),
ContextualError {
context: String,
message: String,
source_error: Option<Box<LlmError>>,
metadata: HashMap<String, String>,
},
Other(String),
}Expand description
The primary error type for the LLM library.
Variants§
HttpError(String)
HTTP request error
JsonError(String)
JSON serialization/deserialization error
ParseError(String)
Response parsing error
InvalidInput(String)
Invalid input error
IoError(String)
IO error
NotFound(String)
Not found error
MissingApiKey(String)
Missing API key
InvalidParameter(String)
Invalid parameter
ApiError
API error response
AuthenticationError(String)
Authentication error
RateLimitError(String)
Rate limit error
QuotaExceededError(String)
Quota exceeded error
ModelNotSupported(String)
Model not supported error
StreamError(String)
Stream processing error
TimeoutError(String)
Timeout error
ConnectionError(String)
Network connection error
ProviderError
Provider-specific error
ConfigurationError(String)
Configuration error
InternalError(String)
Internal error
UnsupportedOperation(String)
Unsupported operation
ProcessingError(String)
Processing error
ToolCallError(String)
Tool call error
ToolValidationError(String)
Tool validation error
UnsupportedToolType(String)
Unsupported tool type
ContextualError
Context-aware error with additional metadata
Fields
Other(String)
Other errors
Implementations§
Source§impl LlmError
impl LlmError
Sourcepub fn api_error_with_details(
code: u16,
message: impl Into<String>,
details: Value,
) -> LlmError
pub fn api_error_with_details( code: u16, message: impl Into<String>, details: Value, ) -> LlmError
Creates a new API error with details.
Sourcepub fn provider_error(
provider: impl Into<String>,
message: impl Into<String>,
) -> LlmError
pub fn provider_error( provider: impl Into<String>, message: impl Into<String>, ) -> LlmError
Creates a new provider error.
Sourcepub fn provider_error_with_code(
provider: impl Into<String>,
message: impl Into<String>,
error_code: impl Into<String>,
) -> LlmError
pub fn provider_error_with_code( provider: impl Into<String>, message: impl Into<String>, error_code: impl Into<String>, ) -> LlmError
Creates a new provider error with an error code.
Sourcepub fn contextual_error(
context: impl Into<String>,
message: impl Into<String>,
) -> LlmError
pub fn contextual_error( context: impl Into<String>, message: impl Into<String>, ) -> LlmError
Creates a new contextual error with metadata.
Sourcepub fn contextual_error_with_source(
context: impl Into<String>,
message: impl Into<String>,
source: LlmError,
) -> LlmError
pub fn contextual_error_with_source( context: impl Into<String>, message: impl Into<String>, source: LlmError, ) -> LlmError
Creates a contextual error with a source error.
Sourcepub fn contextual_error_with_metadata(
context: impl Into<String>,
message: impl Into<String>,
metadata: HashMap<String, String>,
) -> LlmError
pub fn contextual_error_with_metadata( context: impl Into<String>, message: impl Into<String>, metadata: HashMap<String, String>, ) -> LlmError
Creates a contextual error with metadata.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Checks if the error is retryable with more sophisticated logic.
Sourcepub const fn is_auth_error(&self) -> bool
pub const fn is_auth_error(&self) -> bool
Checks if the error is an authentication-related error.
Sourcepub const fn is_rate_limit_error(&self) -> bool
pub const fn is_rate_limit_error(&self) -> bool
Checks if the error is a rate limit error.
Sourcepub const fn status_code(&self) -> Option<u16>
pub const fn status_code(&self) -> Option<u16>
Gets the HTTP status code of the error, if available.
Sourcepub fn category(&self) -> ErrorCategory
pub fn category(&self) -> ErrorCategory
Gets the error category for better error handling.
Sourcepub fn user_message(&self) -> String
pub fn user_message(&self) -> String
Gets a user-friendly error message.
Sourcepub fn recovery_suggestions(&self) -> Vec<String>
pub fn recovery_suggestions(&self) -> Vec<String>
Gets suggested recovery actions for the error with more detailed guidance.
Sourcepub const fn recommended_retry_delay(&self) -> Option<u64>
pub const fn recommended_retry_delay(&self) -> Option<u64>
Gets the recommended retry delay in seconds based on error type.
Sourcepub const fn max_retry_attempts(&self) -> u32
pub const fn max_retry_attempts(&self) -> u32
Gets the maximum number of retry attempts recommended for this error.
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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
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
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.