diff options
| author | Scott Gasch <[email protected]> | 2022-04-08 06:54:04 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2022-04-08 06:54:04 -0700 |
| commit | b69d402dc503a0d38381bfa0fcd6dd5829e92775 (patch) | |
| tree | de3dc7526104fbcdc465fd3b05b962eefdf3171d | |
| parent | 9940cf42dbd246211f34c7d3eecf9fa5be4dd642 (diff) | |
Cause the custom exception handler to also log unhandled exceptions'
tracebacks.
| -rw-r--r-- | bootstrap.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/bootstrap.py b/bootstrap.py index 1174686..a4923b4 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -98,9 +98,15 @@ def handle_uncaught_exception(exc_type, exc_value, exc_tb): ORIGINAL_EXCEPTION_HOOK(exc_type, exc_value, exc_tb) else: # a terminal is attached and stderr is not redirected, maybe debug. + import io import traceback - traceback.print_exception(exc_type, exc_value, exc_tb) + tb_output = io.StringIO() + traceback.print_tb(exc_tb, None, tb_output) + print(tb_output.getvalue(), file=sys.stderr) + logger.error(tb_output.getvalue()) + tb_output.close() + if config.config['debug_unhandled_exceptions']: import pdb |
