jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/894120 )

Change subject: improve flush exception logging
......................................................................

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(-)

Approvals:
  JJMC89: Looks good to me, approved
  jenkins-bot: Verified




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 https://gerrit.wikimedia.org/r/c/pywikibot/core/+/894120
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I75e4aa4c36318f8904419e239b990ef0545b4549
Gerrit-Change-Number: 894120
Gerrit-PatchSet: 2
Gerrit-Owner: JJMC89 <[email protected]>
Gerrit-Reviewer: JJMC89 <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to