Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit be4ab2f

Browse files
authored
Added separate exception for connect timeout error (#101)
1 parent c1c148b commit be4ab2f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

elemental/client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class NotFound(InvalidResponse):
2929
pass
3030

3131

32+
class ConnectionTimeout(ElementalException):
33+
"""Exception raised by 'request' with invalid response"""
34+
pass
35+
36+
3237
EventIdDict = TypedDict('EventIdDict', {'id': str})
3338

3439
EventStatusDict = TypedDict('EventStatusDict', {'origin_url': str, 'backup_url': Optional[str], 'status': str})
@@ -89,6 +94,8 @@ def send_request(self, http_method: str, url: str, headers: Dict[str, str],
8994
response = self.session.request(
9095
method=http_method, url=url, data=body, headers=headers, timeout=timeout)
9196

97+
except requests.exceptions.ConnectTimeout as e:
98+
raise ConnectionTimeout(f"{http_method}: {url} failed\n{e}")
9299
except requests.exceptions.RequestException as e:
93100
raise InvalidRequest(f"{http_method}: {url} failed\n{e}")
94101
if response.status_code == 404:

0 commit comments

Comments
 (0)