summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorp4bl0 <r _at_ uzy .dot. me>2018-06-18 11:53:26 (CEST)
committerp4bl0 <r _at_ uzy .dot. me>2018-06-18 11:53:26 (CEST)
commitbae593053c9804d87568909fdc6e5d31bbf47bf4 (patch)
treea62e26f59f564b7be4d354a5ddf745e5ed5148a9
parent748bda05d251910613cfab23f80315ad27cc84f6 (diff)
downloadseselab-bae593053c9804d87568909fdc6e5d31bbf47bf4.zip
seselab-bae593053c9804d87568909fdc6e5d31bbf47bf4.tar.gz
refactor runtime error management
-rw-r--r--cpu.py13
-rw-r--r--exn.py4
2 files changed, 9 insertions, 8 deletions
diff --git a/cpu.py b/cpu.py
index da6ca1d..cec28ff 100644
--- a/cpu.py
+++ b/cpu.py
@@ -147,11 +147,16 @@ class CPU:
return True
except AddrError as e:
- print('Invalid address ' + str(e.addr) + self.dbg(self._ip), file=sys.stderr)
- except ValError as e:
- print('Invalid value ' + str(e.val) + self.dbg(self._ip), file=sys.stderr)
+ print('Invalid address ' + str(e.addr) +
+ ' on line ' + str(self._code[self._ip][1][1]) +
+ ' of file ' + self._code[self._ip][1][0],
+ file=sys.stderr)
+
except WriteError:
- print('Invalid write ' + self.dbg(self._ip), file=sys.stderr)
+ print('Invalid write ' +
+ ' on line ' + str(self._code[self._ip][1][1]) +
+ ' of file ' + self._code[self._ip][1][0],
+ file=sys.stderr)
def run (self):
while self.cycle():
diff --git a/exn.py b/exn.py
index 963e1bb..92ed003 100644
--- a/exn.py
+++ b/exn.py
@@ -16,10 +16,6 @@ class AddrError (Exception):
def __init__ (self, addr):
self.addr = addr
-class ValError (Exception):
- def __init__ (self, val):
- self.val = val
-
class WriteError (Exception):
def __init__ (self):
pass
Pablo Rauzy — generated by cgit