Use RequestError in tradfri (#67101)

This commit is contained in:
Martin Hjelmare 2022-02-23 09:34:32 +01:00 committed by GitHub
parent c11663344d
commit 93247d7933
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -5,7 +5,7 @@ from datetime import datetime, timedelta
import logging import logging
from typing import Any from typing import Any
from pytradfri import Gateway, PytradfriError, RequestError from pytradfri import Gateway, RequestError
from pytradfri.api.aiocoap_api import APIFactory from pytradfri.api.aiocoap_api import APIFactory
from pytradfri.command import Command from pytradfri.command import Command
from pytradfri.device import Device from pytradfri.device import Device
@ -149,7 +149,7 @@ async def async_setup_entry(
) )
groups = await api(groups_commands, timeout=TIMEOUT_API) groups = await api(groups_commands, timeout=TIMEOUT_API)
except PytradfriError as exc: except RequestError as exc:
await factory.shutdown() await factory.shutdown()
raise ConfigEntryNotReady from exc raise ConfigEntryNotReady from exc

View File

@ -9,7 +9,7 @@ from typing import Any, cast
from pytradfri.command import Command from pytradfri.command import Command
from pytradfri.device import Device from pytradfri.device import Device
from pytradfri.error import PytradfriError from pytradfri.error import RequestError
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
@ -31,7 +31,7 @@ def handle_error(
"""Decorate api call.""" """Decorate api call."""
try: try:
await func(command) await func(command)
except PytradfriError as err: except RequestError as err:
_LOGGER.error("Unable to execute command %s: %s", command, err) _LOGGER.error("Unable to execute command %s: %s", command, err)
return wrapper return wrapper