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

Commit

Permalink
Added separate exception for connect timeout error (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
njannupreddy authored Jul 27, 2021
1 parent c1c148b commit be4ab2f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions elemental/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class NotFound(InvalidResponse):
pass


class ConnectionTimeout(ElementalException):
"""Exception raised by 'request' with invalid response"""
pass


EventIdDict = TypedDict('EventIdDict', {'id': str})

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

except requests.exceptions.ConnectTimeout as e:
raise ConnectionTimeout(f"{http_method}: {url} failed\n{e}")
except requests.exceptions.RequestException as e:
raise InvalidRequest(f"{http_method}: {url} failed\n{e}")
if response.status_code == 404:
Expand Down

0 comments on commit be4ab2f

Please # to comment.