Skip to content

Commit 7aa502a

Browse files
committed
Add runtime error info
1 parent a03be48 commit 7aa502a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

main.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!.venv/bin/python3
2+
import sys
3+
24
import typer
35
from antlr4 import CommonTokenStream, InputStream, ParseTreeWalker
46
from rich.console import Console
@@ -90,8 +92,12 @@ def run(filename: str):
9092
visitor = SemanticAnalyser()
9193
visitor.visit(tree)
9294
if parser.getNumberOfSyntaxErrors() == 0:
93-
visitor = Interpreter()
94-
visitor.visit(tree)
95+
try:
96+
visitor = Interpreter()
97+
visitor.visit(tree)
98+
except Exception:
99+
err_console.print("[bold red]runtime error")
100+
sys.exit(1)
95101

96102

97103
if __name__ == "__main__":

0 commit comments

Comments
 (0)