From 3dfa605d9d78587212a05fe133666a749c3525aa Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Fri, 6 Jan 2017 10:03:17 +0100 Subject: [PATCH] Log a message when a QtNetworkReply errors out --- ghost/ghost.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ghost/ghost.py b/ghost/ghost.py index 3abb94a..a551c15 100755 --- a/ghost/ghost.py +++ b/ghost/ghost.py @@ -275,6 +275,7 @@ def createRequest(self, operation, request, data): reply.downloadProgress.connect( partial(reply_download_progress, reply) ) + reply.error.connect(partial(self._reply_error_callback, reply)) self.logger.debug('Registring reply for %s', reply.url().toString()) self._registry[id(reply)] = reply @@ -282,6 +283,11 @@ def createRequest(self, operation, request, data): time.sleep(0.001) return reply + def _reply_error_callback(self, reply, error_code): + """Log an error message on QtNetworkReply error.""" + self.logger.debug('Reply for %s encountered an error: %s', + reply.url().toString(), reply.errorString()) + def _reply_finished_callback(self, reply): """Unregister a complete QNetworkReply.""" self.logger.debug('Reply for %s complete', reply.url().toString())