Skip to content

Commit

Permalink
Do not create traceback on catching system exit, convert to RuntimeEr…
Browse files Browse the repository at this point in the history
…ror in case of raises
  • Loading branch information
maxnoe committed Jul 15, 2024
1 parent 65a4f82 commit a8df05e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ctapipe/core/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,11 @@ def run(self, argv=None, raises=False):
# Do nothing if SystemExit was called with the exit code 0 (e.g. with -h option)
if exit_status != 0:
if raises:
raise # do not re-intercept in tests
raise RuntimeError(
f"Tool unexpectedly exited with status code {exit_status}"
) from err
else:
self.log.exception(
self.log.critical(
"Caught SystemExit with exit code %s", exit_status
)
Provenance().finish_activity(
Expand Down

0 comments on commit a8df05e

Please sign in to comment.