Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch if the response is None to make typelinting happy #430

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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