Commit 77fdbdc8 authored by Kunshan Wang's avatar Kunshan Wang

Do not inherit from BaseException

parent 34bea3d6
class Exit(BaseException):
class Exit(Exception):
Use an exit exception to end program execution.
We don't use sys.exit because it is a little problematic with RPython.
......@@ -7,7 +7,7 @@ from .method_generation_context import MethodGenerationContext
from .symbol import Symbol, symbol_as_str
class ParseError(BaseException):
class ParseError(Exception):
def __init__(self, message, expected_sym, parser):
self._message = message
self._line = parser._lexer.get_current_line_number()
class ReturnException(BaseException):
class ReturnException(Exception):
_immutable_fields_ = ["_result", "_target"]
......@@ -4,7 +4,9 @@
import sys
from som.vm.universe import main, Exit
from som.interpreter.control_flow import ReturnException
import os
# __________ Entry points __________
......@@ -13,6 +15,14 @@ def entry_point(argv):
except Exit, e:
return e.code
except ReturnException, e:
os.write(2, "ERROR: Caught ReturnException in entry_point. result: %s, target: %s\n" %
(e._result, e._target))
return 1
except Exception, e:
os.write(2, "ERROR: Exception thrown during execution: " + str(e) + "\n")
return 1
os.write(2, "ERROR: Program exited without raising the Exit exception.\n")
return 1
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment