Skip to main content

ark_relations/utils/
error.rs

1use core::fmt;
2
3/// This is an error that could occur during circuit synthesis.
4#[derive(PartialEq, Eq, Clone, Copy, Debug)]
5pub enum SynthesisError {
6    /// During synthesis, we tried to allocate a variable when
7    /// `ConstraintSystemRef` was `None`.
8    MissingCS,
9    /// During synthesis, we lacked knowledge of a variable assignment.
10    AssignmentMissing,
11    /// During synthesis, we divided by zero.
12    DivisionByZero,
13    /// During synthesis, we constructed an unsatisfiable constraint system.
14    Unsatisfiable,
15    /// During synthesis, our polynomials ended up being too high of degree
16    PolynomialDegreeTooLarge,
17    /// The string does not match to any predicate
18    PredicateNotFound,
19    /// The predicate expects a different arity
20    ArityMismatch,
21}
22
23impl ark_std::error::Error for SynthesisError {}
24
25impl fmt::Display for SynthesisError {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
27        match self {
28            SynthesisError::MissingCS => write!(f, "the constraint system was `None`"),
29            SynthesisError::AssignmentMissing => write!(f, "assignment couldn't be computed"),
30            SynthesisError::DivisionByZero => write!(f, "division by zero"),
31            SynthesisError::Unsatisfiable => write!(f, "unsatisfiable constraint system"),
32            SynthesisError::PolynomialDegreeTooLarge => write!(f, "polynomial degree too large"),
33            SynthesisError::ArityMismatch => write!(f, "predicate arity doesn't match input"),
34            SynthesisError::PredicateNotFound => write!(f, "predicate was not found"),
35        }
36    }
37}