pub struct LlmError {
pub kind: LlmErrorKind,
pub message: String,
}Expand description
Classification of LLM provider errors.
Providers emit this as a concrete error type inside anyhow::Error so that
the agent loop can downcast and match on LlmErrorKind instead of
fragile string matching.
Fields§
§kind: LlmErrorKindSemantic category of the error.
message: StringHuman-readable error message (typically includes the provider response body).
Implementations§
Source§impl LlmError
impl LlmError
Sourcepub fn new(kind: LlmErrorKind, message: impl Into<String>) -> Self
pub fn new(kind: LlmErrorKind, message: impl Into<String>) -> Self
Create a new LlmError with the given kind and message.
Sourcepub fn classify(message: impl Into<String>) -> Self
pub fn classify(message: impl Into<String>) -> Self
Classify an error message string into the appropriate LlmErrorKind.
This inspects the message for well-known patterns returned by LLM APIs (OpenAI, Anthropic, Ollama, etc.) and picks the most specific kind.
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Returns true if this error is recoverable through compaction or
conversation truncation.
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)>
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()
Auto Trait Implementations§
impl Forget for LlmError
impl Freeze for LlmError
impl Move 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
Mutably borrows from an owned value. Read more