1#[derive(Debug, thiserror::Error)]
3pub enum LlmError {
4 #[error("HTTP error: {0}")]
6 Http(#[from] reqwest::Error),
7 #[error("API error ({status}): {body}")]
9 Api { status: u16, body: String },
10 #[error("Deserialize error: {0}")]
12 Deserialize(String),
13 #[error("Stream interrupted: {0}")]
15 StreamInterrupted(String),
16 #[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}