Skip to content

Commit

Permalink
Add exceptions handling when loading custom checker
Browse files Browse the repository at this point in the history
  • Loading branch information
nl78 committed Jul 2, 2024
1 parent 75966ac commit 982240f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fmutool/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ def _add_checkers_from_file(checker_filename: str):
return
try:
checker_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(checker_module)
try:
spec.loader.exec_module(checker_module)
except (ModuleNotFoundError, SyntaxError) as error:
print(f"ERROR: Cannot load {checker_filename}: {error})")
return

for checker_name, checker_class in inspect.getmembers(checker_module, inspect.isclass):
if OperationAbstract in checker_class.__bases__:
checker_list.append(checker_class)
Expand Down

0 comments on commit 982240f

Please sign in to comment.