Use http status constants more, add HTTP_ACCEPTED and HTTP_BAD_GATEWAY (#39993)

* Use http status codes and add HTTP_BAD_GATEWAY constant

* Address review comments:
 - using constants in tado integration
 - using constant in media_player init.py

* Add and use HTTP_ACCEPTED constant
This commit is contained in:
springstan 2020-09-15 19:01:07 +02:00 committed by GitHub
parent 59d610af17
commit db582bdc1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 137 additions and 58 deletions

View file

@ -7,7 +7,12 @@ from bond_api import Bond
import voluptuous as vol
from homeassistant import config_entries, exceptions
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, CONF_NAME
from homeassistant.const import (
CONF_ACCESS_TOKEN,
CONF_HOST,
CONF_NAME,
HTTP_UNAUTHORIZED,
)
from .const import CONF_BOND_ID
from .const import DOMAIN # pylint:disable=unused-import
@ -31,7 +36,7 @@ async def _validate_input(data: Dict[str, Any]) -> str:
except ClientConnectionError as error:
raise InputValidationError("cannot_connect") from error
except ClientResponseError as error:
if error.status == 401:
if error.status == HTTP_UNAUTHORIZED:
raise InputValidationError("invalid_auth") from error
raise InputValidationError("unknown") from error
except Exception as error: