Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add PrecompileError::Other #1165

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading