Improve errors

This commit is contained in:
Bartłomiej Pluta
2019-06-30 20:05:23 +02:00
parent 65353a80f2
commit d0b3a8b3da
8 changed files with 105 additions and 94 deletions

View File

@@ -1,2 +1,9 @@
class ParseError(Exception):
pass
class SyntaxException(Exception):
def __init__(self, pos, msg):
posStr = "" if pos is None else f"[line {pos[0]+1}, col {pos[1]+1}]"
self.msg = f"Syntax error {posStr}:\n{msg}"
class RuntimeException(Exception):
def __init__(self, pos, msg):
posStr = "" if pos is None else f"[line {pos[0]+1}, col {pos[1]+1}]"
self.msg = f"Syntax error {posStr}:\n{msg}"