use static_assertions::const_assert;
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum Error {
#[error("Missing plaintext modulus constraint")]
MissingPlainModulusConstraint,
#[error("Failed to find satisfying parameters")]
NoParams,
#[error("Incorrect scheme")]
IncorrectScheme,
#[error("No programs")]
NoPrograms,
#[error("Scheme mismatch")]
SchemeMismatch,
#[error("Name collision")]
NameCollision,
#[error("Cannot create encryption scheme from parameters")]
SealEncryptionParameterError,
#[error("The given constraint cannot be satisfied")]
UnsatisfiableConstraint,
#[error("SEAL error: {0}")]
SealError(#[from] seal_fhe::Error),
#[error("Runtime error: {0}")]
RuntimeError(#[from] crate::RuntimeError),
#[error("FHE program error: {0}")]
FheProgramError(sunscreen_fhe_program::Error),
#[error("Unsupported: {0}")]
Unsupported(Box<String>),
}
const_assert!(std::mem::size_of::<Error>() <= 24);
impl Error {
pub fn unsupported(msg: &str) -> Self {
Self::Unsupported(Box::new(msg.to_owned()))
}
}
pub type Result<T> = std::result::Result<T, Error>;