From e03e34ddedd45a84c9499629e88aeda7f42e7228 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Sat, 19 Oct 2024 02:10:41 +0000 Subject: [PATCH] commands: make die() print a stack trace when -vvv or more Print a stack trace when debugging with -vvv or more. This is MUCH faster than `git grep error_message` and it's even more useful when the same error message is used in multiple places! Example: die_already() in project.py Signed-off-by: Marc Herbert --- src/west/commands.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/west/commands.py b/src/west/commands.py index 1abb0fcd..cad13425 100644 --- a/src/west/commands.py +++ b/src/west/commands.py @@ -511,7 +511,11 @@ def die(self, *args, exit_code: int = 1) -> NoReturn: Equivalent to ``die(*args, fatal=True)``, followed by an attempt to abort with the given *exit_code*.''' self.err(*args, fatal=True) - sys.exit(exit_code) + if self.verbosity >= Verbosity.DBG_EXTREME: + raise RuntimeError("die with -vvv or more shows a stack trace. " + "exit_code argument is ignored.") + else: + sys.exit(exit_code) @property def color_ui(self) -> bool: