mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-12 02:18:02 +00:00
Rename and deprecate exception classes (#739)
# Public # SmartDeviceException -> KasaException UnsupportedDeviceException(SmartDeviceException) -> UnsupportedDeviceError(KasaException) TimeoutException(SmartDeviceException, asyncio.TimeoutError) -> TimeoutError(KasaException, asyncio.TimeoutError) Add new exception for error codes -> DeviceError(KasaException) AuthenticationException(SmartDeviceException) -> AuthenticationError(DeviceError) # Internal # RetryableException(SmartDeviceException) -> _RetryableError(DeviceError) ConnectionException(SmartDeviceException) -> _ConnectionError(KasaException)
This commit is contained in:
@@ -8,9 +8,9 @@ from yarl import URL
|
||||
|
||||
from .deviceconfig import DeviceConfig
|
||||
from .exceptions import (
|
||||
ConnectionException,
|
||||
SmartDeviceException,
|
||||
TimeoutException,
|
||||
KasaException,
|
||||
TimeoutError,
|
||||
_ConnectionError,
|
||||
)
|
||||
from .json import loads as json_loads
|
||||
|
||||
@@ -86,17 +86,17 @@ class HttpClient:
|
||||
response_data = json_loads(response_data.decode())
|
||||
|
||||
except (aiohttp.ServerDisconnectedError, aiohttp.ClientOSError) as ex:
|
||||
raise ConnectionException(
|
||||
raise _ConnectionError(
|
||||
f"Device connection error: {self._config.host}: {ex}", ex
|
||||
) from ex
|
||||
except (aiohttp.ServerTimeoutError, asyncio.TimeoutError) as ex:
|
||||
raise TimeoutException(
|
||||
raise TimeoutError(
|
||||
"Unable to query the device, "
|
||||
+ f"timed out: {self._config.host}: {ex}",
|
||||
ex,
|
||||
) from ex
|
||||
except Exception as ex:
|
||||
raise SmartDeviceException(
|
||||
raise KasaException(
|
||||
f"Unable to query the device: {self._config.host}: {ex}", ex
|
||||
) from ex
|
||||
|
||||
|
Reference in New Issue
Block a user