Fix issue with timeout and error response (#46584)

This commit is contained in:
Joakim Sørensen 2021-02-15 20:08:08 +01:00 committed by GitHub
parent 89aaeb3c35
commit 68809e9f43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,7 +61,7 @@ async def websocket_supervisor_event(
vol.Required(ATTR_ENDPOINT): cv.string, vol.Required(ATTR_ENDPOINT): cv.string,
vol.Required(ATTR_METHOD): cv.string, vol.Required(ATTR_METHOD): cv.string,
vol.Optional(ATTR_DATA): dict, vol.Optional(ATTR_DATA): dict,
vol.Optional(ATTR_TIMEOUT): cv.string, vol.Optional(ATTR_TIMEOUT): vol.Any(cv.Number, None),
} }
) )
async def websocket_supervisor_api( async def websocket_supervisor_api(
@ -79,6 +79,8 @@ async def websocket_supervisor_api(
) )
except hass.components.hassio.HassioAPIError as err: except hass.components.hassio.HassioAPIError as err:
_LOGGER.error("Failed to to call %s - %s", msg[ATTR_ENDPOINT], err) _LOGGER.error("Failed to to call %s - %s", msg[ATTR_ENDPOINT], err)
connection.send_error(msg[WS_ID], err) connection.send_error(
msg[WS_ID], code=websocket_api.ERR_UNKNOWN_ERROR, message=str(err)
)
else: else:
connection.send_result(msg[WS_ID], result[ATTR_DATA]) connection.send_result(msg[WS_ID], result.get(ATTR_DATA, {}))