miden_core/
errors.rs

1use alloc::string::String;
2
3use miden_formatting::hex::DisplayHex;
4
5// INPUT ERROR
6// ================================================================================================
7
8#[derive(Clone, Debug, thiserror::Error)]
9pub enum InputError {
10    #[error("{:#x} is a duplicate of the current merkle set", DisplayHex(.0.as_slice()))]
11    DuplicateAdviceRoot([u8; 32]),
12    #[error("number of input values can not exceed {0}, but {1} was provided")]
13    InputLengthExceeded(usize, usize),
14    #[error("{0} is not a valid field element: {1}")]
15    NotFieldElement(u64, String),
16}
17
18// OUTPUT ERROR
19// ================================================================================================
20
21#[derive(Clone, Debug, thiserror::Error)]
22pub enum OutputError {
23    #[error("overflow addresses contains invalid field element: {0}")]
24    InvalidOverflowAddress(String),
25    #[error("overflow addresses length is {0}, but expected {1}")]
26    InvalidOverflowAddressLength(usize, usize),
27    #[error("stack contains an invalid field element: {0}")]
28    InvalidStackElement(String),
29    #[error("too many elements for output stack, {0} elements")]
30    OutputSizeTooBig(usize),
31}
32
33// KERNEL ERROR
34// ================================================================================================
35
36#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
37pub enum KernelError {
38    #[error("kernel cannot have duplicated procedures")]
39    DuplicatedProcedures,
40    #[error("kernel can have at most {0} procedures, received {1}")]
41    TooManyProcedures(usize, usize),
42}