[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.
This commit is contained in:
Calum Lind 2018-11-16 13:03:10 +00:00
parent bf4244e8b2
commit 157f6ff62a
1 changed files with 9 additions and 1 deletions

View File

@ -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):