Skip to content

Commit

Permalink
commands: make die() print a stack trace when -vvv or more
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
marc-hb committed Oct 19, 2024
1 parent c3aadf5 commit 3f87df7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/west/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3f87df7

Please sign in to comment.