binius_m3/builder/
error.rs

1// Copyright 2025 Irreducible Inc.
2
3use std::cell::{BorrowError, BorrowMutError};
4
5use binius_core::{oracle::Error as OracleError, polynomial::Error as PolynomialError};
6use binius_math::Error as MathError;
7
8use super::{column::ColumnId, structured::Error as StructuredError, table::TableId};
9
10#[derive(Debug, thiserror::Error)]
11pub enum Error {
12	#[error("missing table with ID: {table_id}")]
13	MissingTable { table_id: TableId },
14	#[error("missing column with ID: {0:?}")]
15	MissingColumn(ColumnId),
16	#[error("missing partition with log_vals_per_row={log_vals_per_row} in table {table_id}")]
17	MissingPartition {
18		table_id: TableId,
19		log_vals_per_row: usize,
20	},
21	#[error("cannot construct witness index for empty table {table_id}")]
22	EmptyTable { table_id: TableId },
23	#[error("failed to write element to a column with a lower tower height")]
24	FieldElementTooBig,
25	#[error("structured column error: {0}")]
26	Structured(#[from] StructuredError),
27	#[error("table {table_id} index has already been initialized")]
28	TableIndexAlreadyInitialized { table_id: TableId },
29	#[error(
30		"column is not in table; column table ID: {column_table_id}, witness table ID: {witness_table_id}"
31	)]
32	TableMismatch {
33		column_table_id: TableId,
34		witness_table_id: TableId,
35	},
36	#[error("table {table_id} is required to have a power-of-two size, instead got {size}")]
37	TableSizePowerOfTwoRequired { table_id: TableId, size: usize },
38	#[error("table {table_id} is required to have a fixed power-of-two size, instead got {size}")]
39	TableSizeFixedRequired { table_id: TableId, size: usize },
40	// TODO: These should have column IDs
41	#[error(
42		"witness borrow error: {0}. Note that packed columns are aliases for the unpacked column when accessing witness data"
43	)]
44	WitnessBorrow(#[source] BorrowError),
45	#[error(
46		"witness borrow error: {0}. Note that packed columns are aliases for the unpacked column when accessing witness data"
47	)]
48	WitnessBorrowMut(#[source] BorrowMutError),
49	#[error(
50		"the table index was initialized for {expected} events; attempted to fill with {actual}"
51	)]
52	IncorrectNumberOfTableEvents { expected: usize, actual: usize },
53	#[error("table fill error: {0}")]
54	TableFill(anyhow::Error),
55	#[error("math error: {0}")]
56	Math(#[from] MathError),
57	#[error("oracle error: {0}")]
58	Oracle(#[from] OracleError),
59	#[error("polynomial error: {0}")]
60	Polynomial(#[from] PolynomialError),
61}