jenkins-bot submitted this change.
improve flush exception logging
* log the traceback
* show the exception value in the critical message
Change-Id: I75e4aa4c36318f8904419e239b990ef0545b4549
---
M pywikibot/comms/http.py
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 7828acf..2f345ce 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -34,6 +34,7 @@
import codecs
import re
import sys
+import traceback
from contextlib import suppress
from http import HTTPStatus, cookiejar
from string import Formatter
@@ -115,7 +116,19 @@
session.close()
if hasattr(sys, 'last_type'):
- critical(f'Exiting due to uncaught exception {sys.last_type}')
+ log(
+ ''.join(
+ traceback.format_exception(
+ sys.last_type,
+ value=sys.last_value,
+ tb=sys.last_traceback
+ )
+ )
+ )
+ critical(
+ f'Exiting due to uncaught exception {sys.last_type.__name__}: '
+ f'{sys.last_value}'
+ )
log('Network session closed.')
To view, visit change 894120. To unsubscribe, or for help writing mail filters, visit settings.