1// Copyright 2023-2025 Irreducible Inc.
23use std::ops::Range;
45use binius_field::Error as FieldError;
67#[derive(Debug, thiserror::Error)]
8pub enum Error {
9#[error("the query must have size {expected}")]
10IncorrectQuerySize { expected: usize },
11#[error("all polynomials in mixed composition should have {expected} vars")]
12IncorrectArityInMixedComposition { expected: usize },
13#[error("array of inner composition evaluations is of incorrect length")]
14IncorrectInnerEvalsLength,
15#[error("the polynomial is expected to have {expected} variables, and instead has {actual}")]
16IncorrectNumberOfVariables { expected: usize, actual: usize },
17#[error("block size must between 1 and {n_vars} (inclusive)")]
18InvalidBlockSize { n_vars: usize },
19#[error("shift offset must be between 1 and {max_shift_offset} inclusive, got {shift_offset}")]
20InvalidShiftOffset {
21 max_shift_offset: usize,
22 shift_offset: usize,
23 },
24#[error("invalid tower height: {actual}. tower height must be 0, 3, 4, 5, 6, or 7")]
25InvalidTowerHeight { actual: usize },
26#[error("indices provided to IndexComposition constructor do not match number of variables")]
27IndexCompositionIndicesOutOfBounds,
28#[error("mixed polynomial was not provided")]
29MixedMultilinearNotFound,
30#[error("MultilinearComposite constructed with incorrect arguments: {0}")]
31MultilinearCompositeValidation(String),
32#[error("argument {arg} must be in the range {range:?}")]
33ArgumentRangeError { arg: String, range: Range<usize> },
34#[error("{0}")]
35FieldError(#[from] FieldError),
36#[error("not enough field elements to fill a single packed field element ({length} / {packed_width})")]
37PackedFieldNotFilled { length: usize, packed_width: usize },
38#[error("one of the defining inputs to the ring switching eq-indicator function has length {actual}, rather than {expected}")]
39RingSwitchWrongLength { expected: usize, actual: usize },
40#[error("{0}")]
41MathError(#[from] binius_math::Error),
42#[error("{0}")]
43HalError(#[from] binius_hal::Error),
44}