pub enum LLMError {
Show 13 variants
HttpError(String),
AuthError {
message: String,
status_code: Option<u16>,
response_body: Option<Box<str>>,
},
RateLimitError {
status_code: u16,
message: String,
response_body: Box<str>,
retry_after: Option<Duration>,
provider_code: Option<Box<str>>,
},
HttpStatusError {
status_code: u16,
message: String,
response_body: Box<str>,
retry_after: Option<Duration>,
provider_code: Option<Box<str>>,
},
InvalidRequest {
message: String,
status_code: Option<u16>,
response_body: Option<Box<str>>,
},
ProviderError(String),
ResponseFormatError {
message: String,
raw_response: String,
},
Generic(String),
JsonError(String),
ToolConfigError(String),
NoToolSupport(String),
GuardrailBlocked {
phase: GuardrailPhase,
guard: Box<str>,
rule_id: Box<str>,
category: Box<str>,
severity: Box<str>,
message: Box<str>,
},
GuardrailExecutionFailed {
guard: String,
message: String,
},
}Expand description
Error types that can occur when interacting with LLM providers.
Variants§
HttpError(String)
HTTP transport failures (connection, timeout, DNS, etc.).
AuthError
Authentication and authorization errors (missing local API key or HTTP 401/403).
RateLimitError
Rate limit or provider overload (HTTP 429, 529).
Fields
HttpStatusError
Non-success HTTP response that is not auth or rate-limit.
Fields
InvalidRequest
Invalid request parameters, format, or client-side HTTP 4xx rejection.
ProviderError(String)
Errors returned by the LLM provider in a parsed response payload.
ResponseFormatError
API response parsing or format error on a successful HTTP response.
Generic(String)
Generic error (unsupported features, internal stubs).
JsonError(String)
JSON serialization/deserialization errors.
ToolConfigError(String)
Tool configuration error.
NoToolSupport(String)
Provider does not support tool calling.
GuardrailBlocked
Guardrail blocked the request/response.
Fields
phase: GuardrailPhaseGuardrailExecutionFailed
Guardrail execution failed unexpectedly.
Implementations§
Source§impl LLMError
impl LLMError
Sourcepub fn missing_api_key(message: impl Into<String>) -> Self
pub fn missing_api_key(message: impl Into<String>) -> Self
Local configuration error when an API key is missing.
Sourcepub fn invalid_request(message: impl Into<String>) -> Self
pub fn invalid_request(message: impl Into<String>) -> Self
Local validation error for invalid request parameters or configuration.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true when the error represents a transient failure worth retrying.
Sourcepub fn http_status_code(&self) -> Option<u16>
pub fn http_status_code(&self) -> Option<u16>
HTTP status code when the error originated from a non-success response.
Sourcepub fn response_body(&self) -> Option<&str>
pub fn response_body(&self) -> Option<&str>
Provider response body attached to HTTP-related errors.
Sourcepub fn is_transport_retryable(&self) -> bool
pub fn is_transport_retryable(&self) -> bool
Returns true when this HttpError represents a retryable transport failure.
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more