From 157f6ff62a355d42164922015f6da9df3670fea8 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Fri, 16 Nov 2018 13:03:10 +0000 Subject: [PATCH] [WebUI] Catch unhandled 'Bad host id' exception The bad host id error usually occurs on webui when the 'default_daemon' key in web.conf does not exist in hostlist.conf. Added a errback method to output a more useful log message. --- deluge/ui/web/json_api.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index 536a3408c..69eb1e7a2 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -421,6 +421,11 @@ class WebApi(JSONComponent): self.start() return d_methods + def _on_client_connect_fail(self, result, host_id): + log.error( + 'Unable to connect to daemon, check host_id "%s" is correct.', host_id + ) + def _on_client_disconnect(self, *args): component.get('Web.PluginManager').stop() return self.stop() @@ -444,7 +449,10 @@ class WebApi(JSONComponent): Returns: Deferred: List of methods the daemon supports. """ - return self.hostlist.connect_host(host_id).addCallback(self._on_client_connect) + d = self.hostlist.connect_host(host_id) + d.addCallback(self._on_client_connect) + d.addErrback(self._on_client_connect_fail, host_id) + return d @export def connected(self):