#[derive(Debug)]
pub enum Error {
Plonkish(plonkish_cat::Error),
ProofCatCore(proof_cat_core::Error),
WitnessSizeMismatch {
expected: usize,
actual: usize,
},
UnsatisfiedConstraint {
index: usize,
},
EmptyConstraintSet,
}
impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Plonkish(e) => write!(f, "plonkish-cat error: {e}"),
Self::ProofCatCore(e) => write!(f, "proof-cat-core error: {e}"),
Self::WitnessSizeMismatch { expected, actual } => {
write!(
f,
"witness size mismatch: expected {expected}, got {actual}"
)
}
Self::UnsatisfiedConstraint { index } => {
write!(f, "constraint {index} not satisfied by witness")
}
Self::EmptyConstraintSet => write!(f, "constraint set is empty"),
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::Plonkish(e) => Some(e),
Self::ProofCatCore(e) => Some(e),
Self::WitnessSizeMismatch { .. }
| Self::UnsatisfiedConstraint { .. }
| Self::EmptyConstraintSet => None,
}
}
}
impl From<plonkish_cat::Error> for Error {
fn from(e: plonkish_cat::Error) -> Self {
Self::Plonkish(e)
}
}
impl From<proof_cat_core::Error> for Error {
fn from(e: proof_cat_core::Error) -> Self {
Self::ProofCatCore(e)
}
}