use pyo3::prelude::*;
use pyo3::exceptions::{PyIOError, PyValueError, PyRuntimeError};
use crate::core::Error;
pub(crate) fn map_rust_error(error: Error) -> PyErr {
match error {
Error::Io(e) => {
PyIOError::new_err(format!("IO error: {}", e))
}
Error::UnsupportedFormat(mime) => {
PyValueError::new_err(format!("Unsupported format: {}", mime))
}
Error::CorruptedFile(msg) => {
PyValueError::new_err(format!("Corrupted file: {}", msg))
}
Error::ParseError(msg) => {
PyValueError::new_err(format!("Parse error: {}", msg))
}
Error::DetectionFailed(msg) => {
PyRuntimeError::new_err(format!("Detection failed: {}", msg))
}
Error::PartialExtraction { message, partial_result: _ } => {
PyRuntimeError::new_err(format!("Partial extraction: {}", message))
}
}
}