moonproof_runtime/ir/
error.rs1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum IrDriverError {
5 #[error("IR loader error: {0}")]
6 IrLoader(#[from] moonproof_runtime_ir::IrError),
7
8 #[error("unimplemented IR construct: {what}")]
9 Unimplemented { what: String },
10
11 #[error("circuit '{0}' not found in IR")]
12 UnknownCircuit(String),
13
14 #[error("witness '{0}' not found in IR")]
15 UnknownWitness(String),
16
17 #[error("type mismatch: {0}")]
18 TypeMismatch(String),
19
20 #[error("unbound variable '{0}' in circuit body")]
21 UnboundVariable(String),
22
23 #[error("descriptor '{0}' not found in IR descriptor table")]
24 UnknownDescriptor(String),
25
26 #[error("argument count mismatch for {context}: expected {expected}, got {got}")]
27 ArgCount {
28 context: String,
29 expected: usize,
30 got: usize,
31 },
32
33 #[error("witness invocation failed: {0}")]
34 Witness(String),
35
36 #[error("VM op execution failed: {0}")]
37 VmOp(String),
38
39 #[error("assert failed: {0}")]
41 AssertionFailed(String),
42
43 #[error("invalid IR shape: {0}")]
44 InvalidIr(String),
45
46 #[error("cross-contract call failed: {0}")]
47 CrossContract(String),
48}
49
50pub type Result<T> = std::result::Result<T, IrDriverError>;
51
52impl IrDriverError {
53 #[must_use]
54 pub fn unimplemented(what: impl Into<String>) -> Self {
55 Self::Unimplemented { what: what.into() }
56 }
57}