Skip to content

Commit

Permalink
Catch if the response is None to make typelinting happy
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-dxw committed Oct 19, 2023
1 parent 482bfdf commit b89b71f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/caselawclient/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
DEFAULT_USER_AGENT = f"ds-caselaw-marklogic-api-client/{VERSION}"


class NoResponse(Exception):
"""A requests HTTPError has no response. We expect this will never happen."""

pass


class MultipartResponseLongerThanExpected(Exception):
"""
MarkLogic has returned a multipart response with more than one part, where only a single part was expected.
Expand Down Expand Up @@ -236,6 +242,8 @@ def _raise_for_status(self, response: requests.Response) -> None:
try:
response.raise_for_status()
except requests.exceptions.HTTPError as e:
if e.response is None:
raise NoResponse
status_code = e.response.status_code
new_error_class = self.http_error_classes.get(
status_code, self.default_http_error_class
Expand Down

0 comments on commit b89b71f

Please sign in to comment.