| 1 |
"""Exceptions""" |
| 2 |
|
| 3 |
# Default messages |
| 4 |
AUTH_EXPIRED_MESSAGE = 'Ayla Networks API authentication expired. Re-authenticate and retry.' |
| 5 |
AUTH_FAILURE_MESSAGE = 'Error authenticating to Ayla Networks.' |
| 6 |
NOT_AUTHED_MESSAGE = 'Ayla Networks API not authenticated. Authenticate first and retry.' |
| 7 |
|
| 8 |
|
| 9 |
class AylaError(RuntimeError): |
| 10 |
"""Parent class for all Ayla Networks exceptions""" |
| 11 |
|
| 12 |
|
| 13 |
class AylaAuthError(AylaError): |
| 14 |
"""Exception authenticating""" |
| 15 |
def __init__(self, msg=AUTH_FAILURE_MESSAGE, *args): |
| 16 |
super().__init__(msg, *args) |
| 17 |
|
| 18 |
|
| 19 |
class AylaAuthExpiringError(AylaError): |
| 20 |
"""Authentication expired and needs to be refreshed""" |
| 21 |
def __init__(self, msg=AUTH_EXPIRED_MESSAGE, *args): |
| 22 |
super().__init__(msg, *args) |
| 23 |
|
| 24 |
|
| 25 |
class AylaNotAuthedError(AylaError): |
| 26 |
"""Not authorized""" |
| 27 |
def __init__(self, msg=NOT_AUTHED_MESSAGE, *args): |
| 28 |
super().__init__(msg, *args) |
| 29 |
|
| 30 |
|
| 31 |
class AylaReadOnlyPropertyError(AylaError): |
| 32 |
"""Property is read-only and is not allowed to be set.""" |
| 33 |
pass |