#[non_exhaustive]pub enum LlmError {
Api {
status: u16,
message: String,
},
Auth(String),
Transport(String),
Config(String),
RequestFailed(String),
ModelNotAvailable(String),
RateLimited,
ContentFiltered(String),
Other(String),
}Expand description
Errors from LLM operations.
Errors keep what the provider said — the HTTP status, the reason content was blocked — so a caller can decide what to do without parsing a message:
use gemini_adk_rs::llm::LlmError;
let err = LlmError::Api { status: 429, message: "quota exceeded".into() };
assert!(err.is_rate_limited() && err.is_retryable());
assert_eq!(err.status(), Some(429));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Api
The provider answered with an error status.
Auth(String)
Credentials are missing or were rejected. The message says how to fix it.
Transport(String)
The provider could not be reached: connection, TLS or timeout.
Config(String)
The client is configured in a way no request can succeed with. The message says what to change.
RequestFailed(String)
The HTTP request to the LLM API failed for another reason.
ModelNotAvailable(String)
The requested model is not available.
RateLimited
The request was rate-limited by the provider.
ContentFiltered(String)
The prompt or the reply was blocked by content safety; carries the
provider’s reason (e.g. "SAFETY", "PROHIBITED_CONTENT").
Other(String)
A catch-all for other LLM errors.
Implementations§
Source§impl LlmError
impl LlmError
Sourcepub fn status(&self) -> Option<u16>
pub fn status(&self) -> Option<u16>
The HTTP status the provider answered with, when there was one.
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
The provider is rate-limiting or out of quota (HTTP 429).
Sourcepub fn is_auth(&self) -> bool
pub fn is_auth(&self) -> bool
Credentials are missing, invalid or lack permission (HTTP 401/403).
Sourcepub fn is_content_filtered(&self) -> bool
pub fn is_content_filtered(&self) -> bool
The prompt or reply was blocked by content safety.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Trying the same request again later may succeed: rate limits, server errors (5xx) and transport failures. Auth, configuration, content safety and other client errors will fail the same way again.
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
Source§impl From<LlmError> for AgentError
impl From<LlmError> for AgentError
Source§fn from(source: LlmError) -> AgentError
fn from(source: LlmError) -> AgentError
Auto Trait Implementations§
impl Freeze for LlmError
impl RefUnwindSafe for LlmError
impl Send for LlmError
impl Sync for LlmError
impl Unpin 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
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].