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

@@ -4,7 +4,7 @@ from abc import ABC, abstractmethod
from typing import Dict
from .device import Device
from .exceptions import SmartDeviceException
from .exceptions import KasaException
from .feature import Feature
_LOGGER = logging.getLogger(__name__)
@@ -39,7 +39,7 @@ class Module(ABC):
"""Add module feature."""
feat_name = f"{self._module}_{feature.name}"
if feat_name in self._module_features:
raise SmartDeviceException("Duplicate name detected %s" % feat_name)
raise KasaException("Duplicate name detected %s" % feat_name)
self._module_features[feat_name] = feature
def __repr__(self) -> str: