From a9045fa2f1e44b613232846978a5cc50c5922a51 Mon Sep 17 00:00:00 2001 From: Federica Date: Thu, 29 Dec 2022 11:39:32 -0300 Subject: [PATCH] Add rought version of VirtualMachineError::Hint --- src/vm/errors/vm_errors.rs | 2 ++ src/vm/vm_core.rs | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vm/errors/vm_errors.rs b/src/vm/errors/vm_errors.rs index f89ac0c7ce..4a82e38392 100644 --- a/src/vm/errors/vm_errors.rs +++ b/src/vm/errors/vm_errors.rs @@ -240,4 +240,6 @@ pub enum VirtualMachineError { InvalidArgCount(usize, usize), #[error("{0}, {1}")] ErrorMessageAttribute(String, Box), + #[error("{1}")] + Hint(usize, Box), } diff --git a/src/vm/vm_core.rs b/src/vm/vm_core.rs index 7b08a5e6ac..05333969d0 100644 --- a/src/vm/vm_core.rs +++ b/src/vm/vm_core.rs @@ -525,8 +525,10 @@ impl VirtualMachine { constants: &HashMap, ) -> Result<(), VirtualMachineError> { if let Some(hint_list) = hint_data_dictionary.get(&self.run_context.pc.offset) { - for hint_data in hint_list.iter() { - hint_executor.execute_hint(self, exec_scopes, hint_data, constants)? + for (hint_index, hint_data) in hint_list.iter().enumerate() { + hint_executor + .execute_hint(self, exec_scopes, hint_data, constants) + .map_err(|err| VirtualMachineError::Hint(hint_index, Box::new(err)))? } } Ok(())