use thiserror::Error;
use crate::llm::ChatError;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ExpansionError {
#[error("expansion client build failed: {message}")]
Build {
message: String,
},
#[error(
"expansion HTTP error{}: {message}",
.status.map(|s| format!(" ({s})")).unwrap_or_default()
)]
Http {
status: Option<u16>,
message: String,
timed_out: bool,
},
}
impl From<ChatError> for ExpansionError {
fn from(value: ChatError) -> Self {
match value {
ChatError::Build { message } => Self::Build { message },
ChatError::Http {
status,
message,
timed_out,
} => Self::Http {
status,
message,
timed_out,
},
ChatError::MalformedResponse => Self::Http {
status: None,
message: "malformed chat response".to_string(),
timed_out: false,
},
}
}
}