Skip to content

Commit

Permalink
Create Interrupts for ScriptError
Browse files Browse the repository at this point in the history
Signed-off-by: Eval EXEC <[email protected]>
  • Loading branch information
eval-exec committed Nov 25, 2024
1 parent 6fc4b7b commit a724ef7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions script/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -183,9 +187,7 @@ impl ScriptError {
impl From<TransactionScriptError> 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),
}
}
Expand Down
1 change: 1 addition & 0 deletions script/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};

Expand Down

0 comments on commit a724ef7

Please sign in to comment.