From a724ef74ec765296d01b531f025b5b338e141e59 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Mon, 25 Nov 2024 10:52:17 +0800 Subject: [PATCH] Create Interrupts for ScriptError Signed-off-by: Eval EXEC --- script/src/error.rs | 8 +++++--- script/src/verify.rs | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/script/src/error.rs b/script/src/error.rs index 094671d6e3..a6cfcc28a0 100644 --- a/script/src/error.rs +++ b/script/src/error.rs @@ -44,6 +44,10 @@ pub enum ScriptError { #[error("VM Internal Error: {0:?}")] VMInternalError(VMInternalError), + /// Interrupts, such as a Ctrl-C signal + #[error("VM Interrupts")] + Interrupts, + /// Other errors raised in script execution process #[error("Other Error: {0}")] Other(String), @@ -183,9 +187,7 @@ impl ScriptError { impl From for Error { fn from(error: TransactionScriptError) -> Self { match error.cause { - ScriptError::Other(ref reason) if reason == "stopped" => { - ErrorKind::Internal.because(error) - } + ScriptError::Interrupts => ErrorKind::Internal.because(error), _ => ErrorKind::Script.because(error), } } diff --git a/script/src/verify.rs b/script/src/verify.rs index d20afd5ceb..3d13747eda 100644 --- a/script/src/verify.rs +++ b/script/src/verify.rs @@ -1180,6 +1180,7 @@ where let mut scheduler = Scheduler::new(tx_data, version, self.syscalls_generator.clone()); let map_vm_internal_error = |error: VMInternalError| match error { VMInternalError::CyclesExceeded => ScriptError::ExceededMaximumCycles(max_cycles), + VMInternalError::External(reason) if reason.eq("stopped") => ScriptError::Interrupts, _ => ScriptError::VMInternalError(error), };