#[non_exhaustive]pub enum LiterLlmError {
Show 17 variants
Authentication {
message: String,
},
RateLimited {
message: String,
retry_after: Option<Duration>,
},
BadRequest {
message: String,
},
ContextWindowExceeded {
message: String,
},
ContentPolicy {
message: String,
},
NotFound {
message: String,
},
ServerError {
message: String,
},
ServiceUnavailable {
message: String,
},
Timeout,
Network(Error),
Streaming {
message: String,
},
EndpointNotSupported {
endpoint: String,
provider: String,
},
InvalidHeader {
name: String,
reason: String,
},
Serialization(Error),
BudgetExceeded {
message: String,
model: Option<String>,
},
HookRejected {
message: String,
},
InternalError {
message: String,
},
}Expand description
All errors that can occur when using liter-llm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Authentication
RateLimited
BadRequest
ContextWindowExceeded
ContentPolicy
NotFound
ServerError
Timeout
Network(Error)
Streaming
A catch-all for errors that occur during streaming response processing.
This variant covers multiple sub-conditions including UTF-8 decoding
failures, CRC/checksum mismatches (AWS EventStream), JSON parse errors
in individual SSE chunks, and buffer overflow conditions. The message
field contains a human-readable description of the specific failure.
EndpointNotSupported
InvalidHeader
Serialization(Error)
BudgetExceeded
HookRejected
InternalError
An internal logic error (e.g. unexpected Tower response variant).
This should never surface in normal operation — if it does, it indicates a bug in the library.
Implementations§
Source§impl LiterLlmError
impl LiterLlmError
Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
Returns true for errors that are worth retrying on a different service
or deployment (transient failures).
Used by [crate::tower::fallback::FallbackService] and
[crate::tower::router::Router] to decide whether to route to an
alternative endpoint.
Sourcepub fn error_type(&self) -> &'static str
pub fn error_type(&self) -> &'static str
Return the OpenTelemetry error.type string for this error variant.
Used by the tracing middleware to record the error.type span attribute
on failed requests per the GenAI semantic conventions.
Sourcepub fn from_status(
status: u16,
body: &str,
retry_after: Option<Duration>,
) -> Self
pub fn from_status( status: u16, body: &str, retry_after: Option<Duration>, ) -> Self
Create from an HTTP status code, an API error response body, and an
optional Retry-After duration already parsed from the response header.
The retry_after value is forwarded into LiterLlmError::RateLimited
so callers can honour the server-requested delay without re-parsing the
header.
Trait Implementations§
Source§impl Debug for LiterLlmError
impl Debug for LiterLlmError
Source§impl Display for LiterLlmError
impl Display for LiterLlmError
Source§impl Error for LiterLlmError
impl Error for LiterLlmError
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<Error> for LiterLlmError
impl From<Error> for LiterLlmError
Auto Trait Implementations§
impl Freeze for LiterLlmError
impl !RefUnwindSafe for LiterLlmError
impl Send for LiterLlmError
impl Sync for LiterLlmError
impl Unpin for LiterLlmError
impl UnsafeUnpin for LiterLlmError
impl !UnwindSafe for LiterLlmError
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> 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.