mirror of
https://github.com/home-assistant/core
synced 2024-09-28 03:04:04 +02:00
Display error message instead of exception (#4866)
* Display error message instead of exception Display error message in log instead of stack trace. (Usually happens when a server is already running at the same port.) * Update __init__.py Better error handling when reading SSL certificate * Update __init__.py * Update __init__.py
This commit is contained in:
parent
dbb4e4c3fa
commit
12f790c7cf
@ -288,10 +288,16 @@ class HomeAssistantWSGI(object):
|
||||
cors_added.add(route)
|
||||
|
||||
if self.ssl_certificate:
|
||||
context = ssl.SSLContext(SSL_VERSION)
|
||||
context.options |= SSL_OPTS
|
||||
context.set_ciphers(CIPHERS)
|
||||
context.load_cert_chain(self.ssl_certificate, self.ssl_key)
|
||||
try:
|
||||
context = ssl.SSLContext(SSL_VERSION)
|
||||
context.options |= SSL_OPTS
|
||||
context.set_ciphers(CIPHERS)
|
||||
context.load_cert_chain(self.ssl_certificate, self.ssl_key)
|
||||
except OSError as error:
|
||||
_LOGGER.error("Could not read SSL certificate from %s: %s",
|
||||
self.ssl_certificate, error)
|
||||
context = None
|
||||
return
|
||||
else:
|
||||
context = None
|
||||
|
||||
@ -305,8 +311,12 @@ class HomeAssistantWSGI(object):
|
||||
|
||||
self._handler = self.app.make_handler()
|
||||
|
||||
self.server = yield from self.hass.loop.create_server(
|
||||
self._handler, self.server_host, self.server_port, ssl=context)
|
||||
try:
|
||||
self.server = yield from self.hass.loop.create_server(
|
||||
self._handler, self.server_host, self.server_port, ssl=context)
|
||||
except OSError as error:
|
||||
_LOGGER.error("Failed to create HTTP server at port %d: %s",
|
||||
self.server_port, error)
|
||||
|
||||
self.app._frozen = False # pylint: disable=protected-access
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user