pub enum LlmError {
CircuitOpen,
Transport(Error),
Api {
status: u16,
body: String,
},
Decode(Error),
StreamProtocol(String),
InvalidUtf8(FromUtf8Error),
AllRetriesFailed {
attempts: u32,
source: Box<LlmError>,
},
}Expand description
Everything that can go wrong on the way to a completion.
Mirrors the failure modes of the Python llm_completion wrapper, but where
that returned None and swallowed the cause, we keep a typed error so the
caller decides how to degrade.
Variants§
CircuitOpen
Circuit breaker is open — we fail fast without hitting the provider.
Transport(Error)
Transport-level failure (connection, TLS, timeout).
Api
Provider returned a non-2xx status.
Decode(Error)
Response body could not be decoded into the expected shape.
StreamProtocol(String)
A streaming response violated the SSE completion contract.
InvalidUtf8(FromUtf8Error)
A streaming response contained bytes that were not valid UTF-8.
AllRetriesFailed
All retry attempts were exhausted. Carries the last error seen.
Implementations§
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)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<FromUtf8Error> for LlmError
impl From<FromUtf8Error> for LlmError
Source§fn from(source: FromUtf8Error) -> Self
fn from(source: FromUtf8Error) -> Self
Converts to this type from the input type.
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
Mutably borrows from an owned value. Read more