core_utils/circuit/v2/
errors.rs1use primitives::algebra::elliptic_curve::Curve;
2
3use crate::circuit::{AlgebraicType, Gate, GateIndex};
4
5#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
6pub enum ConversionError {
7 #[error("Cannot transform AlgebraicType {0:?} into FieldType")]
8 IntoFieldTypeError(AlgebraicType),
9}
10
11#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
12pub enum SliceError {
13 #[error("Expected non-negative index, found {0}")]
14 NegativeIndex(i128),
15 #[error("Expected index in [0, {max}], found {found}")]
16 IndexOutOfBounds { found: i128, max: u32 },
17}
18
19#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
20#[error("Batch size must be a strictly positive integer, found {0}")]
21pub struct BatchSizeError(pub usize);
22
23#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
24#[error("Internal error: {0}")]
25pub struct InternalError(pub String);
26
27#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
28pub enum CircuitError<C: Curve> {
29 #[error("Invalid gate {0:?}: {1}")]
30 InvalidGate(Gate<C>, String),
31 #[error("Gate index {0} out-of-bounds [0,{1})")]
32 GateIndexOutOfBounds(GateIndex, GateIndex),
33 #[error("Conversion error: {0}")]
34 ConversionError(#[from] ConversionError),
35 #[error("Invalid gate input count, expected {expected} inputs found {found}")]
36 InvalidGateInputCount { expected: usize, found: usize },
37 #[error("Invalid gate algebraic type, expected {expected:?} found {found:?}")]
38 InvalidGateAlgebraicType {
39 expected: AlgebraicType,
40 found: AlgebraicType,
41 },
42 #[error("Circuit is limited to a maximum of 2^32 gates")]
43 CircuitTooBig,
44 #[error("Slice error: {0}")]
45 SliceError(#[from] SliceError),
46 #[error("{0}")]
47 InternalError(#[from] InternalError),
48 #[error("{0}")]
49 BatchSizeError(#[from] BatchSizeError),
50}