Expose more Websocket API constants (#42263)

This commit is contained in:
Paulus Schoutsen 2020-10-25 21:10:13 +01:00 committed by GitHub
parent c157a582b8
commit de12ac354a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 64 additions and 13 deletions

View file

@ -5,7 +5,7 @@ from typing import Any, Callable, Dict, Hashable, Optional
import voluptuous as vol
from homeassistant.core import Context, callback
from homeassistant.exceptions import Unauthorized
from homeassistant.exceptions import HomeAssistantError, Unauthorized
from . import const, messages
@ -118,6 +118,9 @@ class ActiveConnection:
elif isinstance(err, asyncio.TimeoutError):
code = const.ERR_TIMEOUT
err_message = "Timeout"
elif isinstance(err, HomeAssistantError):
code = const.ERR_UNKNOWN_ERROR
err_message = str(err)
else:
code = const.ERR_UNKNOWN_ERROR
err_message = "Unknown error"