Skip to main content

j_agent/llm/
error.rs

1/// LLM client errors (lower level than ChatError)
2#[derive(Debug, thiserror::Error)]
3pub enum LlmError {
4    /// HTTP-level errors (reqwest)
5    #[error("HTTP error: {0}")]
6    Http(#[from] reqwest::Error),
7    /// Non-success HTTP status with body
8    #[error("API error ({status}): {body}")]
9    Api { status: u16, body: String },
10    /// JSON deserialization failures
11    #[error("Deserialize error: {0}")]
12    Deserialize(String),
13    /// SSE stream interrupted
14    #[error("Stream interrupted: {0}")]
15    StreamInterrupted(String),
16    /// Request build error
17    #[error("Request build error: {0}")]
18    RequestBuild(String),
19}
20
21impl From<serde_json::Error> for LlmError {
22    fn from(e: serde_json::Error) -> Self {
23        LlmError::Deserialize(e.to_string())
24    }
25}