use std::path::PathBuf;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum MappingError {
#[error("Failed to read schema file: {path}")]
SchemaReadError {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("Failed to parse schema: {0}")]
SchemaParseError(String),
#[error("Invalid schema structure: {0}")]
InvalidSchema(String),
#[error("No field mappings could be determined between source and target schemas")]
NoMappingsFound,
#[error("Schemas are incompatible: {0}")]
IncompatibleSchemas(String),
#[error("Failed to generate transformation: {0}")]
TransformGenerationError(String),
#[error("IO error: {0}")]
IoError(#[from] std::io::Error),
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
#[error("LLM error: {0}")]
LlmError(String),
}
pub type MappingResult<T> = Result<T, MappingError>;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_error_display() {
let err = MappingError::NoMappingsFound;
assert!(err.to_string().contains("No field mappings"));
let err = MappingError::InvalidSchema("missing properties".to_string());
assert!(err.to_string().contains("missing properties"));
}
}