From 00757af1491539067dbefdc842ad878b70a43daa Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Thu, 30 Jan 2014 11:54:47 +0000 Subject: [PATCH] [Core] Empty error message fix with certain trackers By design alert.msg will be empty if the error code is '-1' so use a.e.message() to get the message as fallback. It was not used at replacement because when error code is not '-1' then a.e.message() will also include the error code, which we do not want. --- deluge/core/torrentmanager.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 8c87b37df..4f66dbe79 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -1043,13 +1043,19 @@ class TorrentManager(component.Component): torrent.set_tracker_status(tracker_status) def on_alert_tracker_error(self, alert): - log.debug("on_alert_tracker_error") + """Alert handler for libtorrent tracker_error_alert""" + error_message = decode_string(alert.msg) + # If alert.msg is empty then it's a '-1' code so fallback to a.e.message. Note that alert.msg + # cannot be replaced by a.e.message because the code is included in the string (for non-'-1'). + if not error_message: + error_message = decode_string(alert.error.message()) + log.debug("Tracker Error Alert: %s [%s]", decode_string(alert.message()), error_message) try: torrent = self.torrents[str(alert.handle.info_hash())] - except: + except (RuntimeError, KeyError): return - tracker_status = "%s: %s" % (_("Error"), alert.msg) - torrent.set_tracker_status(tracker_status) + + torrent.set_tracker_status("Error: " + error_message) def on_alert_storage_moved(self, alert): log.debug("on_alert_storage_moved")