Skip to content

Commit

Permalink
feat: add PrecompileError::Other (#1165)
Browse files Browse the repository at this point in the history
* feat: add PrecompileError::Other

* add PrecomileError::other
  • Loading branch information
fgimenez authored Mar 7, 2024
1 parent b6bde3d commit ac99931
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crates/primitives/src/precompile.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{Bytes, Env};
use core::fmt;
use dyn_clone::DynClone;
use std::{boxed::Box, sync::Arc};
use std::{boxed::Box, string::String, sync::Arc};

/// A precompile operation result.
///
Expand Down Expand Up @@ -125,6 +125,14 @@ pub enum PrecompileError {
BlobMismatchedVersion,
/// The proof verification failed.
BlobVerifyKzgProofFailed,
/// Catch-all variant for other errors.
Other(String),
}

impl PrecompileError {
pub fn other(err: impl Into<String>) -> Self {
Self::Other(err.into())
}
}

#[cfg(feature = "std")]
Expand Down Expand Up @@ -153,6 +161,9 @@ impl fmt::Display for PrecompileError {
PrecompileError::BlobVerifyKzgProofFailed => {
write!(f, "verifying blob kzg proof failed")
}
PrecompileError::Other(why) => {
write!(f, "other precompile error: {why}")
}
}
}
}
Expand Down

0 comments on commit ac99931

Please sign in to comment.