mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-16 21:56:29 +00:00
Better error handling for proxy (#334)
This commit is contained in:
parent
eb6c753514
commit
142cdcffca
@ -4,7 +4,7 @@ import logging
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from aiohttp.web_exceptions import HTTPBadGateway
|
from aiohttp.web_exceptions import HTTPBadGateway, HTTPInternalServerError
|
||||||
from aiohttp.hdrs import CONTENT_TYPE
|
from aiohttp.hdrs import CONTENT_TYPE
|
||||||
import async_timeout
|
import async_timeout
|
||||||
|
|
||||||
@ -133,15 +133,19 @@ class APIProxy(CoreSysAttributes):
|
|||||||
await server.prepare(request)
|
await server.prepare(request)
|
||||||
|
|
||||||
# handle authentication
|
# handle authentication
|
||||||
await server.send_json({
|
try:
|
||||||
'type': 'auth_required',
|
await server.send_json({
|
||||||
'ha_version': self._homeassistant.version,
|
'type': 'auth_required',
|
||||||
})
|
'ha_version': self._homeassistant.version,
|
||||||
await server.receive_json() # get internal token
|
})
|
||||||
await server.send_json({
|
await server.receive_json() # get internal token
|
||||||
'type': 'auth_ok',
|
await server.send_json({
|
||||||
'ha_version': self._homeassistant.version,
|
'type': 'auth_ok',
|
||||||
})
|
'ha_version': self._homeassistant.version,
|
||||||
|
})
|
||||||
|
except RuntimeError as err:
|
||||||
|
_LOGGER.error("Can't initialize handshake: %s", err)
|
||||||
|
raise HTTPInternalServerError() from None
|
||||||
|
|
||||||
# init connection to hass
|
# init connection to hass
|
||||||
client = await self._websocket_client()
|
client = await self._websocket_client()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user