mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-12-06 16:18:21 +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:
@@ -23,7 +23,7 @@ from typing import Dict, Generator, Optional
|
||||
from async_timeout import timeout as asyncio_timeout
|
||||
|
||||
from .deviceconfig import DeviceConfig
|
||||
from .exceptions import RetryableException, SmartDeviceException
|
||||
from .exceptions import KasaException, _RetryableError
|
||||
from .json import loads as json_loads
|
||||
from .protocol import BaseTransport
|
||||
|
||||
@@ -129,24 +129,24 @@ class XorTransport(BaseTransport):
|
||||
await self._connect(self._timeout)
|
||||
except ConnectionRefusedError as ex:
|
||||
await self.reset()
|
||||
raise SmartDeviceException(
|
||||
raise KasaException(
|
||||
f"Unable to connect to the device: {self._host}:{self._port}: {ex}"
|
||||
) from ex
|
||||
except OSError as ex:
|
||||
await self.reset()
|
||||
if ex.errno in _NO_RETRY_ERRORS:
|
||||
raise SmartDeviceException(
|
||||
raise KasaException(
|
||||
f"Unable to connect to the device:"
|
||||
f" {self._host}:{self._port}: {ex}"
|
||||
) from ex
|
||||
else:
|
||||
raise RetryableException(
|
||||
raise _RetryableError(
|
||||
f"Unable to connect to the device:"
|
||||
f" {self._host}:{self._port}: {ex}"
|
||||
) from ex
|
||||
except Exception as ex:
|
||||
await self.reset()
|
||||
raise RetryableException(
|
||||
raise _RetryableError(
|
||||
f"Unable to connect to the device:" f" {self._host}:{self._port}: {ex}"
|
||||
) from ex
|
||||
except BaseException:
|
||||
@@ -162,7 +162,7 @@ class XorTransport(BaseTransport):
|
||||
return await self._execute_send(request)
|
||||
except Exception as ex:
|
||||
await self.reset()
|
||||
raise RetryableException(
|
||||
raise _RetryableError(
|
||||
f"Unable to query the device {self._host}:{self._port}: {ex}"
|
||||
) from ex
|
||||
except BaseException:
|
||||
|
||||
Reference in New Issue
Block a user