alloy_trie/proof/
error.rsuse alloy_primitives::{Bytes, B256};
use core::fmt;
use nybbles::Nibbles;
#[derive(PartialEq, Eq, Debug)]
pub enum ProofVerificationError {
RootMismatch {
got: B256,
expected: B256,
},
ValueMismatch {
path: Nibbles,
got: Option<Bytes>,
expected: Option<Bytes>,
},
UnexpectedEmptyRoot,
Rlp(alloy_rlp::Error),
}
#[cfg(feature = "std")]
impl std::error::Error for ProofVerificationError {
fn source(&self) -> ::core::option::Option<&(dyn std::error::Error + 'static)> {
#[allow(deprecated)]
match self {
Self::Rlp { 0: transparent } => {
std::error::Error::source(transparent as &dyn std::error::Error)
}
_ => None,
}
}
}
impl fmt::Display for ProofVerificationError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::RootMismatch { got, expected } => {
write!(f, "root mismatch. got: {got}. expected: {expected}")
}
Self::ValueMismatch { path, got, expected } => {
write!(f, "value mismatch at path {path:?}. got: {got:?}. expected: {expected:?}")
}
Self::UnexpectedEmptyRoot => {
write!(f, "unexpected empty root node")
}
Self::Rlp(error) => fmt::Display::fmt(error, f),
}
}
}
impl From<alloy_rlp::Error> for ProofVerificationError {
fn from(source: alloy_rlp::Error) -> Self {
Self::Rlp(source)
}
}