Skip to content

Commit 7f64f10

Browse files
committed
Add basic error handling to console entry point
1 parent 7a4aa40 commit 7f64f10

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/hermes/commands/cli.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
This module provides the main entry point for the HERMES command line application.
1010
"""
1111
import argparse
12+
import sys
1213

1314
from hermes import logger
1415
from hermes.commands import HermesHelpCommand, HermesCleanCommand, HermesHarvestCommand, HermesProcessCommand, \
@@ -58,7 +59,22 @@ def main() -> None:
5859
args = parser.parse_args()
5960

6061
logger.init_logging()
62+
log = logger.getLogger("hermes.cli")
63+
log.debug("Running hermes with the following command line arguments: %s", args)
6164

62-
args.command.load_settings(args)
63-
args.command.patch_settings(args)
64-
args.command(args)
65+
try:
66+
log.info("Loading settings...")
67+
args.command.load_settings(args)
68+
69+
log.debug("Update settings from command line...")
70+
args.command.patch_settings(args)
71+
72+
log.info("Run subcommand %s", args.command.command_name)
73+
args.command(args)
74+
except BaseException as e:
75+
log.error("An error occurred during execution of %s", args.command.command_name)
76+
log.debug("Original exception was: %s", e)
77+
78+
sys.exit(1)
79+
80+
sys.exit(0)

0 commit comments

Comments
 (0)