From 8ba63d38a37e143464cf7f1e0f8793fc81d2c8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Autin?= Date: Mon, 27 Mar 2023 10:21:18 +0200 Subject: [PATCH] :recycle: Main loop now panics on error --- src/simulator/machine.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/simulator/machine.rs b/src/simulator/machine.rs index 5ba058b..4c7ea58 100644 --- a/src/simulator/machine.rs +++ b/src/simulator/machine.rs @@ -208,9 +208,13 @@ impl Machine { /// ### Parameters /// /// - **machine** which contains a table of instructions - pub fn run(&mut self){ - while let Ok(()) = Machine::one_instruction(self) {} - println!("trace : \n{}", self.registers_trace); + pub fn run(&mut self) { + loop { + match Machine::one_instruction(self) { + Ok(()) => (), + Err(e) => panic!("FATAL at pc {} -> {}", self.pc, e) + } + } } /// Execute the current instruction