use thiserror::Error;
#[derive(Debug, Error)]
pub enum VerificationError {
#[error("dimension mismatch: expected {expected}, got {actual}")]
DimensionMismatch {
expected: u32,
actual: u32,
},
#[error("type check failed: {0}")]
TypeCheckFailed(String),
#[error("proof construction failed: {0}")]
ProofConstructionFailed(String),
#[error("conversion timeout: exceeded {max_reductions} reduction steps")]
ConversionTimeout {
max_reductions: u32,
},
#[error("unification failed: {0}")]
UnificationFailed(String),
#[error("arena exhausted: {allocated} terms allocated")]
ArenaExhausted {
allocated: u32,
},
#[error("declaration not found: {name}")]
DeclarationNotFound {
name: String,
},
#[error("attestation error: {0}")]
AttestationError(String),
}
pub type Result<T> = std::result::Result<T, VerificationError>;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn error_display_dimension_mismatch() {
let e = VerificationError::DimensionMismatch { expected: 128, actual: 256 };
assert_eq!(e.to_string(), "dimension mismatch: expected 128, got 256");
}
#[test]
fn error_display_type_check() {
let e = VerificationError::TypeCheckFailed("bad term".into());
assert_eq!(e.to_string(), "type check failed: bad term");
}
#[test]
fn error_display_timeout() {
let e = VerificationError::ConversionTimeout { max_reductions: 10000 };
assert_eq!(e.to_string(), "conversion timeout: exceeded 10000 reduction steps");
}
#[test]
fn error_display_arena() {
let e = VerificationError::ArenaExhausted { allocated: 42 };
assert_eq!(e.to_string(), "arena exhausted: 42 terms allocated");
}
#[test]
fn error_display_attestation() {
let e = VerificationError::AttestationError("sig invalid".into());
assert_eq!(e.to_string(), "attestation error: sig invalid");
}
}