use pyo3::PyErr;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum StrSimError {
#[error("Invalid input data: {0}")]
InvalidInputData(String),
#[error("Invalid configuration: {0}")]
InvalidConfigData(String),
#[error("Integrity error - asking for an entity that isn't in the database: {0}")]
DBIntegrityError(String),
#[error("Generic integrity error: {0}")]
IntegrityError(String),
#[error("Logic error: {0}")]
LogicError(String),
#[error("Invalid arguments: {0}")]
InvalidArgument(String),
#[error(transparent)]
IOError(#[from] std::io::Error),
#[error(transparent)]
PyErr(#[from] pyo3::PyErr),
#[error(transparent)]
LSAPErr(#[from] lsap::LSAPError),
}
pub fn into_pyerr<E: Into<StrSimError>>(err: E) -> PyErr {
let hderr = err.into();
if let StrSimError::PyErr(e) = hderr {
e
} else {
let anyerror: anyhow::Error = hderr.into();
anyerror.into()
}
}