diff --git a/Cargo.lock b/Cargo.lock index f968e2e..20eb915 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1813,7 +1813,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "svc16" -version = "0.6.0" +version = "0.6.1" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 702c6fd..ac8a394 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "svc16" -version = "0.6.0" +version = "0.6.1" edition = "2021" authors = ["Jan Neuendorf"] description = "An emulator for a simple virtual computer" diff --git a/src/engine.rs b/src/engine.rs index 9cc8389..4b60e1b 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -36,8 +36,8 @@ pub enum EngineError { #[error("Division by zero")] ZeroDivision, - #[error("Invalid instruction")] - InvalidInstruction, + #[error("Invalid instruction {0}")] + InvalidInstruction(u16), } impl Engine { @@ -216,7 +216,7 @@ impl Engine { } self.advance_inst_ptr(); } - _ => return Err(EngineError::InvalidInstruction), + _ => return Err(EngineError::InvalidInstruction(opcode)), } Ok(()) } diff --git a/src/main.rs b/src/main.rs index 6b26d4a..20747c2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,8 +87,11 @@ fn main() -> Result<()> { let engine_start = Instant::now(); while !engine.wants_to_sync() && ipf <= cli.max_ipf && !paused { match engine.step() { - Err(_) => { - handle_event_loop_error(&elwt, "Invalid operation"); + Err(e) => { + handle_event_loop_error( + &elwt, + format!("{} (after {} instructions)", e, ipf), + ); return; } _ => {}