mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-04 09:44:14 +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:
@@ -100,6 +100,17 @@ The classes providing this functionality are:
|
||||
- :class:`KlapTransport <kasa.klaptransport.KlapTransport>`
|
||||
- :class:`KlapTransportV2 <kasa.klaptransport.KlapTransportV2>`
|
||||
|
||||
Errors and Exceptions
|
||||
*********************
|
||||
|
||||
The base exception for all library errors is :class:`KasaException <kasa.exceptions.KasaException>`.
|
||||
|
||||
- If the device returns an error the library raises a :class:`DeviceError <kasa.exceptions.DeviceError>` which will usually contain an ``error_code`` with the detail.
|
||||
- If the device fails to authenticate the library raises an :class:`AuthenticationError <kasa.exceptions.AuthenticationError>` which is derived
|
||||
from :class:`DeviceError <kasa.exceptions.DeviceError>` and could contain an ``error_code`` depending on the type of failure.
|
||||
- If the library encounters and unsupported deviceit raises an :class:`UnsupportedDeviceError <kasa.exceptions.UnsupportedDeviceError>`.
|
||||
- If the device fails to respond within a timeout the library raises a :class:`TimeoutError <kasa.exceptions.TimeoutError>`.
|
||||
- All other failures will raise the base :class:`KasaException <kasa.exceptions.KasaException>` class.
|
||||
|
||||
API documentation for modules
|
||||
*****************************
|
||||
@@ -154,3 +165,26 @@ API documentation for protocols and transports
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
API documentation for errors and exceptions
|
||||
*******************************************
|
||||
|
||||
.. autoclass:: kasa.exceptions.KasaException
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. autoclass:: kasa.exceptions.DeviceError
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. autoclass:: kasa.exceptions.AuthenticationError
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. autoclass:: kasa.exceptions.UnsupportedDeviceError
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. autoclass:: kasa.exceptions.TimeoutError
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
@@ -24,7 +24,7 @@ Methods changing the state of the device do not invalidate the cache (i.e., ther
|
||||
You can assume that the operation has succeeded if no exception is raised.
|
||||
These methods will return the device response, which can be useful for some use cases.
|
||||
|
||||
Errors are raised as :class:`SmartDeviceException` instances for the library user to handle.
|
||||
Errors are raised as :class:`KasaException` instances for the library user to handle.
|
||||
|
||||
Simple example script showing some functionality for legacy devices:
|
||||
|
||||
@@ -154,15 +154,3 @@ API documentation
|
||||
.. autoclass:: Credentials
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. autoclass:: SmartDeviceException
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. autoclass:: AuthenticationException
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. autoclass:: UnsupportedDeviceException
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
Reference in New Issue
Block a user