mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-23 05:35:44 -05:00
main.py: always print at least the beginning and end of the stack trace
This commit is contained in:
parent
42d7a701fb
commit
7ab4904cbc
1 changed files with 13 additions and 3 deletions
16
main.py
16
main.py
|
@ -3,7 +3,7 @@
|
||||||
import click
|
import click
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from traceback import format_exc as get_trace
|
from traceback import format_exc, format_exception_only, format_tb
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from logger import logging, setup_logging, verbose_option
|
from logger import logging, setup_logging, verbose_option
|
||||||
|
@ -40,9 +40,19 @@ def main():
|
||||||
return cli(prog_name='kupferbootstrap')
|
return cli(prog_name='kupferbootstrap')
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
if config.runtime.verbose:
|
if config.runtime.verbose:
|
||||||
logging.fatal(get_trace())
|
msg = format_exc()
|
||||||
else:
|
else:
|
||||||
logging.fatal(ex)
|
tb_start = ''.join(format_tb(ex.__traceback__, limit=1)).strip('\n')
|
||||||
|
tb_end = ''.join(format_tb(ex.__traceback__, limit=-1)).strip('\n')
|
||||||
|
short_tb = [
|
||||||
|
'Traceback (most recent call last):',
|
||||||
|
tb_start,
|
||||||
|
'[...]',
|
||||||
|
tb_end,
|
||||||
|
format_exception_only(ex)[-1], # type: ignore[arg-type]
|
||||||
|
]
|
||||||
|
msg = '\n'.join(short_tb)
|
||||||
|
logging.fatal('\n' + msg)
|
||||||
if config.runtime.error_shell:
|
if config.runtime.error_shell:
|
||||||
logging.info('Starting error shell. Type exit to quit.')
|
logging.info('Starting error shell. Type exit to quit.')
|
||||||
subprocess.call('/bin/bash')
|
subprocess.call('/bin/bash')
|
||||||
|
|
Loading…
Add table
Reference in a new issue