Skip to content

Commit

Permalink
register_file now catches exceptions in all cases
Browse files Browse the repository at this point in the history
  • Loading branch information
florianschanda committed Sep 21, 2023
1 parent 5723124 commit 8879e65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion trlc/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def __init__(self, mh, file_name, file_content=None):
try:
super().__init__(mh, fd.read())
except UnicodeDecodeError as err:
mh.error(Location(file_name), str(err))
mh.lex_error(Location(file_name), str(err))

def current_location(self):
# lobster-exclude: Utility function
Expand Down
21 changes: 11 additions & 10 deletions trlc/trlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,20 @@ def register_file(self, file_name, file_content=None):
# lobster-trace: LRM.Layout

ok = True
if file_name.endswith(".rsl"):
try:
try:
if file_name.endswith(".rsl"):
self.register_rsl_file(file_name, file_content)
except TRLC_Error:
elif file_name.endswith(".check"):
self.register_check_file(file_name, file_content)
elif file_name.endswith(".trlc"):
self.register_trlc_file(file_name, file_content)
else:
ok = False
elif file_name.endswith(".check"):
self.register_check_file(file_name, file_content)
elif file_name.endswith(".trlc"):
self.register_trlc_file(file_name, file_content)
else:
self.mh.error(Location(os.path.basename(file_name)),
"is not a rsl, check, or trlc file",
fatal = False)
except TRLC_Error:
ok = False
self.mh.error(Location(os.path.basename(file_name)),
"is not a rsl, check, or trlc file")

return ok

Expand Down

0 comments on commit 8879e65

Please sign in to comment.