Skip to content

Commit c6dec10

Browse files
authored
Update exceptions documentation (#1499)
1 parent 39c94bb commit c6dec10

2 files changed

Lines changed: 37 additions & 28 deletions

File tree

pyoverkiz/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
NexityBadCredentialsException,
5454
NexityServiceException,
5555
NoRegisteredEventListenerException,
56+
NoSuchResourceException,
5657
NotAuthenticatedException,
5758
NotSuchTokenException,
5859
OverkizException,
@@ -1023,6 +1024,10 @@ async def check_response(response: ClientResponse) -> None:
10231024
if message == "No registered event listener":
10241025
raise NoRegisteredEventListenerException(message)
10251026

1027+
# {'errorCode': 'INVALID_API_CALL', 'error': 'No such resource'}
1028+
if message == "No such resource":
1029+
raise NoSuchResourceException(message)
1030+
10261031
# {"errorCode": "RESOURCE_ACCESS_DENIED", "error": "too many concurrent requests"}
10271032
if message == "too many concurrent requests":
10281033
raise TooManyConcurrentRequestsException(message)
@@ -1054,7 +1059,7 @@ async def check_response(response: ClientResponse) -> None:
10541059
if "Access denied to gateway" in message:
10551060
raise AccessDeniedToGatewayException(message)
10561061

1057-
# General Overkiz exception
1062+
# Undefined Overkiz exception
10581063
raise OverkizException(result)
10591064

10601065
async def _refresh_token_if_expired(self) -> None:

pyoverkiz/exceptions.py

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,113 @@
11
class BaseOverkizException(Exception):
2-
pass
2+
"""Base exception for Overkiz errors."""
33

44

55
class OverkizException(BaseOverkizException):
6-
pass
6+
"""Raised when an undefined error occurs while communicating with the Overkiz API."""
77

88

99
class BadCredentialsException(BaseOverkizException):
10-
pass
10+
"""Raised when invalid credentials are provided."""
1111

1212

1313
class InvalidCommandException(BaseOverkizException):
14-
pass
14+
"""Raised when an invalid command is provided."""
15+
16+
17+
class NoSuchResourceException(BaseOverkizException):
18+
"""Raised when an invalid API call is made."""
1519

1620

1721
class NotAuthenticatedException(BaseOverkizException):
18-
pass
22+
"""Raised when the user is not authenticated."""
1923

2024

2125
class TooManyExecutionsException(BaseOverkizException):
22-
pass
26+
"""Raised when too many executions are requested."""
2327

2428

2529
class ExecutionQueueFullException(BaseOverkizException):
26-
pass
30+
"""Raised when the execution queue is full."""
2731

2832

2933
class TooManyRequestsException(BaseOverkizException):
30-
pass
34+
"""Raised when too many requests are made."""
3135

3236

3337
class TooManyConcurrentRequestsException(BaseOverkizException):
34-
pass
38+
"""Raised when too many concurrent requests are made."""
3539

3640

3741
class ServiceUnavailableException(BaseOverkizException):
38-
pass
42+
"""Raised when the service is unavailable."""
3943

4044

4145
class MaintenanceException(ServiceUnavailableException):
42-
pass
46+
"""Raised when the service is under maintenance."""
4347

4448

4549
class MissingAuthorizationTokenException(BaseOverkizException):
46-
pass
50+
"""Raised when the authorization token is missing."""
4751

4852

4953
class InvalidEventListenerIdException(BaseOverkizException):
50-
pass
54+
"""Raised when an invalid event listener ID is provided."""
5155

5256

5357
class NoRegisteredEventListenerException(BaseOverkizException):
54-
pass
58+
"""Raised when no event listener is registered."""
5559

5660

5761
class SessionAndBearerInSameRequestException(BaseOverkizException):
58-
pass
62+
"""Raised when both session and bearer are provided in the same request."""
5963

6064

6165
class TooManyAttemptsBannedException(BaseOverkizException):
62-
pass
66+
"""Raised when too many attempts are made and the user is (temporarily) banned."""
6367

6468

6569
class InvalidTokenException(BaseOverkizException):
66-
pass
70+
"""Raised when an invalid token is provided."""
6771

6872

6973
class NotSuchTokenException(BaseOverkizException):
70-
pass
74+
"""Raised when an invalid token is provided."""
7175

7276

7377
class UnknownUserException(BaseOverkizException):
74-
pass
78+
"""Raised when an unknown user is provided."""
7579

7680

7781
class UnknownObjectException(BaseOverkizException):
78-
pass
82+
"""Raised when an unknown object is provided."""
7983

8084

8185
class AccessDeniedToGatewayException(BaseOverkizException):
82-
pass
86+
"""Raised when access is denied to the gateway. This often happens when the user is not the owner of the gateway."""
8387

8488

8589
# Nexity
8690
class NexityBadCredentialsException(BadCredentialsException):
87-
pass
91+
"""Raised when invalid credentials are provided to Nexity authentication API."""
8892

8993

9094
class NexityServiceException(BaseOverkizException):
91-
pass
95+
"""Raised when an error occurs while communicating with the Nexity API."""
9296

9397

9498
# CozyTouch
9599
class CozyTouchBadCredentialsException(BadCredentialsException):
96-
pass
100+
"""Raised when invalid credentials are provided to CozyTouch authentication API."""
97101

98102

99103
class CozyTouchServiceException(BaseOverkizException):
100-
pass
104+
"""Raised when an error occurs while communicating with the CozyTouch API."""
101105

102106

103107
# Somfy
104108
class SomfyBadCredentialsException(BadCredentialsException):
105-
pass
109+
"""Raised when invalid credentials are provided to Somfy authentication API."""
106110

107111

108112
class SomfyServiceException(BaseOverkizException):
109-
pass
113+
"""Raised when an error occurs while communicating with the Somfy API."""

0 commit comments

Comments
 (0)