Skip to content

Commit 054ff45

Browse files
committed
Handle ReadTimeout
1 parent 812213c commit 054ff45

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

pylitterbot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2021.10.0"
1+
__version__ = "2021.10.1"
22

33
from .account import Account
44
from .robot import Robot

pylitterbot/account.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
from typing import Optional, Set
44

5-
from httpx import ConnectError, ConnectTimeout, HTTPStatusError
5+
from httpx import ConnectError, ConnectTimeout, HTTPStatusError, ReadTimeout
66

77
from .exceptions import LitterRobotException, LitterRobotLoginException
88
from .litterrobot import LitterRobot
@@ -56,7 +56,7 @@ async def connect(
5656
) from ex
5757
else:
5858
raise LitterRobotException("Unable to login to Litter-Robot.") from ex
59-
except (ConnectError, ConnectTimeout) as ex:
59+
except (ConnectError, ConnectTimeout, ReadTimeout) as ex:
6060
raise LitterRobotException(
6161
"Unable to communicate with the Litter-Robot API."
6262
) from ex

pylitterbot/session.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
from urllib.parse import urljoin
55

66
from authlib.integrations.httpx_client import AsyncOAuth2Client
7-
from httpx import ConnectError, ConnectTimeout, HTTPError, HTTPStatusError, Response
7+
from httpx import (
8+
ConnectError,
9+
ConnectTimeout,
10+
HTTPError,
11+
HTTPStatusError,
12+
ReadTimeout,
13+
Response,
14+
)
815

916
from .exceptions import InvalidCommandException, LitterRobotException
1017
from .litterrobot import LitterRobot, Vendor
@@ -100,7 +107,13 @@ async def call(self, method: MethodType, path: str, **kwargs) -> Response:
100107
response = await method(url, headers=headers, **kwargs)
101108
response.raise_for_status()
102109
return response
103-
except (HTTPStatusError, HTTPError, ConnectTimeout, ConnectError) as ex:
110+
except (
111+
HTTPStatusError,
112+
HTTPError,
113+
ConnectTimeout,
114+
ConnectError,
115+
ReadTimeout,
116+
) as ex:
104117
if isinstance(ex, HTTPStatusError) and ex.response.status_code == 500:
105118
raise InvalidCommandException(
106119
f"{ex.response.json()['developerMessage']} sent to Litter-Robot"

0 commit comments

Comments
 (0)