[elbe-devel] [PATCH 2/3] elbepack: main: wrap entrypoint with improved exception reporting
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Thu Jul 18 14:47:25 CEST 2024
Use the elbepack.cli library to implement human-readable reporting of
exceptions.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/main.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/elbepack/main.py b/elbepack/main.py
index 6e2217b3f2bb..93ec9bf008de 100644
--- a/elbepack/main.py
+++ b/elbepack/main.py
@@ -5,6 +5,8 @@
import importlib
import sys
+import elbepack
+from elbepack.cli import format_exception
from elbepack.directories import get_cmdlist
from elbepack.version import elbe_version
@@ -30,6 +32,11 @@ def main():
print('elbe v%s' % (elbe_version))
sys.exit(0)
+ verbose = False
+ if sys.argv[1] == '--stacktrace-on-error':
+ verbose = True
+ sys.argv.pop(1)
+
cmd_list = get_cmdlist()
if sys.argv[1] not in cmd_list:
@@ -41,4 +48,7 @@ def main():
cmdmod = importlib.import_module(modname)
- cmdmod.run_command(sys.argv[2:])
+ try:
+ cmdmod.run_command(sys.argv[2:])
+ except Exception as e:
+ sys.exit(format_exception(e, output=sys.stderr, verbose=verbose, base_module=elbepack))
--
2.45.2
More information about the elbe-devel
mailing list