pub enum LlmError {
Transport(Error),
ApiError {
status: u16,
body: String,
},
Deserialise {
source: Error,
body: String,
},
MissingConfig(String),
Bedrock(String),
}Expand description
Error type returned by LlmClient operations.
Why: Library code must expose structured errors rather than anyhow::Error
so consumers can programmatically handle recoverable failures (e.g.
rate-limit → retry, invalid API key → fast-fail).
What: Covers network transport errors, non-200 HTTP responses with an
optional API-level error body, and response deserialisation failures.
Test: llm_error_display.
Variants§
Transport(Error)
The HTTP transport layer failed (connection refused, TLS error, timeout).
Why: Distinct from API errors so callers can apply retry logic to transient network failures without retrying on e.g. invalid-key errors.
ApiError
The API returned a non-2xx status code.
Why: Callers need both the status code and the raw body to decide whether to retry (e.g. 429 Too Many Requests) or give up (e.g. 401 Unauthorized).
Deserialise
The response body could not be deserialised into ChatResponse.
Why: Separates schema-mismatch problems (usually provider bugs or version drift) from transport and API-level issues.
Fields
MissingConfig(String)
A required configuration value is missing.
Why: Failing at construction time with a clear message is better than receiving a cryptic 401 from the API.
Bedrock(String)
An AWS Bedrock Converse-API-level failure (#1021 phase 1): SDK transport/auth/validation/throttling errors, or a request/response shape the Converse transport could not build.
Why: Bedrock errors arrive as aws_sdk_bedrockruntime SDK error types,
not reqwest::Error or an HTTP status code, so they don’t fit
Self::Transport or Self::ApiError. Carrying the SDK’s own
Display text (rather than inventing a fake status code) keeps the
error message honest.
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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<LlmError> for ToolCallExtractError
impl From<LlmError> for ToolCallExtractError
Auto Trait Implementations§
impl !RefUnwindSafe for LlmError
impl !UnwindSafe for LlmError
impl Freeze for LlmError
impl Send for LlmError
impl Sync for LlmError
impl Unpin for LlmError
impl UnsafeUnpin 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> 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