Skip to content

Commit

Permalink
improve package problem error output
Browse files Browse the repository at this point in the history
  • Loading branch information
ImogenBits committed Nov 27, 2023
1 parent 145a114 commit d039342
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion algobattle/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from rich.theme import Theme
from rich.rule import Rule
from rich.padding import Padding
from rich.traceback import Traceback
from tomlkit import TOMLDocument, comment, parse as parse_toml, dumps as dumps_toml, table, nl as toml_newline
from tomlkit.exceptions import ParseError
from tomlkit.items import Table as TomlTable
Expand Down Expand Up @@ -516,9 +517,17 @@ def package_problem(
try:
with console.status("Loading problem"):
parsed_config.loaded_problem
except (ValueError, RuntimeError) as e:
except ValueError as e:
console.print(f"[error]Couldn't load the problem file[/]\nError: {e}")
raise Abort
except RuntimeError as e:
error = e.__cause__
if error is None:
console.print(f"[error]Couldn't load the problem file[/]\nError: {e}")
raise Abort
trace = Traceback.from_exception(error.__class__, error, error.__traceback__)
console.print("[error]Couldn't execute the problem file[/]\nError:", trace)
raise Abort

if "project" in config_doc:
config_doc.remove("project")
Expand Down

0 comments on commit d039342

Please sign in to comment.