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:
Steven B
2024-02-21 15:52:55 +00:00
committed by GitHub
parent 4beff228c9
commit 8c39e81a40
44 changed files with 393 additions and 361 deletions

View File

@@ -2,7 +2,7 @@
from enum import Enum
from typing import Optional
from ...exceptions import SmartDeviceException
from ...exceptions import KasaException
from ..iotmodule import IotModule
@@ -54,9 +54,7 @@ class Motion(IotModule):
elif range is not None:
payload = {"index": range.value}
else:
raise SmartDeviceException(
"Either range or custom_range need to be defined"
)
raise KasaException("Either range or custom_range need to be defined")
return await self.call("set_trigger_sens", payload)

View File

@@ -1,7 +1,7 @@
"""Provides the current time and timezone information."""
from datetime import datetime
from ...exceptions import SmartDeviceException
from ...exceptions import KasaException
from ..iotmodule import IotModule, merge
@@ -46,7 +46,7 @@ class Time(IotModule):
res["min"],
res["sec"],
)
except SmartDeviceException:
except KasaException:
return None
async def get_timezone(self):