jenkins-bot submitted this change.

View Change


Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
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.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I75e4aa4c36318f8904419e239b990ef0545b4549
Gerrit-Change-Number: 894120
Gerrit-PatchSet: 2
Gerrit-Owner: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged