1#[derive(Debug)]
5pub enum Error {
6 Plonkish(plonkish_cat::Error),
8 ProofCatCore(proof_cat_core::Error),
10 WitnessSizeMismatch {
12 expected: usize,
14 actual: usize,
16 },
17 UnsatisfiedConstraint {
19 index: usize,
21 },
22 EmptyConstraintSet,
24}
25
26impl core::fmt::Display for Error {
27 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
28 match self {
29 Self::Plonkish(e) => write!(f, "plonkish-cat error: {e}"),
30 Self::ProofCatCore(e) => write!(f, "proof-cat-core error: {e}"),
31 Self::WitnessSizeMismatch { expected, actual } => {
32 write!(
33 f,
34 "witness size mismatch: expected {expected}, got {actual}"
35 )
36 }
37 Self::UnsatisfiedConstraint { index } => {
38 write!(f, "constraint {index} not satisfied by witness")
39 }
40 Self::EmptyConstraintSet => write!(f, "constraint set is empty"),
41 }
42 }
43}
44
45impl std::error::Error for Error {
46 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
47 match self {
48 Self::Plonkish(e) => Some(e),
49 Self::ProofCatCore(e) => Some(e),
50 Self::WitnessSizeMismatch { .. }
51 | Self::UnsatisfiedConstraint { .. }
52 | Self::EmptyConstraintSet => None,
53 }
54 }
55}
56
57impl From<plonkish_cat::Error> for Error {
58 fn from(e: plonkish_cat::Error) -> Self {
59 Self::Plonkish(e)
60 }
61}
62
63impl From<proof_cat_core::Error> for Error {
64 fn from(e: proof_cat_core::Error) -> Self {
65 Self::ProofCatCore(e)
66 }
67}