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 <marc.herbert@intel.com>
This commit is contained in:
Marc Herbert 2024-10-19 02:10:41 +00:00 committed by Pieter De Gendt
parent d36e887b5e
commit e03e34dded
1 changed files with 5 additions and 1 deletions

View File

@ -511,7 +511,11 @@ class WestCommand(ABC):
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: