From 8ba1701c9f475c4b7214c928a6246e15b62d6993 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Mon, 9 Feb 2026 21:47:13 -0500 Subject: [PATCH] Dump instruction trace for all error exceptions, not just illegal opcode Wrap opcode execution with try-except to catch all ZCpuError subclasses except ZCpuQuit and ZCpuRestart, which are normal control flow. This ensures we get trace dumps for divide by zero, not implemented, and other errors. --- src/mudlib/zmachine/zcpu.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mudlib/zmachine/zcpu.py b/src/mudlib/zmachine/zcpu.py index 596c1d0..0fc6e3f 100644 --- a/src/mudlib/zmachine/zcpu.py +++ b/src/mudlib/zmachine/zcpu.py @@ -216,7 +216,15 @@ class ZCpu: # The returned function is unbound, so we must pass # self to it ourselves. - func(self, *operands) + try: + func(self, *operands) + except (ZCpuQuit, ZCpuRestart): + # Normal control flow - don't dump trace + raise + except ZCpuError: + # All other ZCpu errors - dump trace for debugging + self._dump_trace() + raise return True def run(self):