use reqwest;
use serde_json;
#[derive(Debug)]
pub enum TransformError {
SerializationError(serde_json::Error),
DeserializationError(serde_json::Error),
RequestError(reqwest::Error),
ApiError {
status: reqwest::StatusCode,
body: String,
},
EnvVarError(String),
TimeoutError,
InvalidResponseFormat,
}
impl std::fmt::Display for TransformError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
TransformError::SerializationError(e) => {
write!(f, "Failed to serialize source value: {e}")
}
TransformError::DeserializationError(e) => {
write!(f, "Failed to deserialize target value: {e}")
}
TransformError::RequestError(e) => write!(f, "HTTP request failed: {e}"),
TransformError::ApiError { status, body } => {
write!(f, "OpenAI API error: {status} - {body}")
}
TransformError::EnvVarError(var) => {
write!(f, "Environment variable not found: {var}")
}
TransformError::TimeoutError => write!(f, "Timeout waiting for response"),
TransformError::InvalidResponseFormat => write!(f, "Invalid response format"),
}
}
}
impl std::error::Error for TransformError {}