Skip to content

Commit

Permalink
Improve error message in case of a redirect (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
gtopper authored Mar 31, 2024
1 parent 883d72c commit 723c7c9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions v3io/dataplane/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ def raise_for_status(self, expected_statuses=None):
if (expected_statuses is None and self.status_code >= 300) or (
expected_statuses and self.status_code not in expected_statuses
):
raise HttpResponseError(
"Request failed with status {0}: {1}".format(self.status_code, self.body), status_code=self.status_code
)
if 308 <= self.status_code < 400:
location = self.headers.get("Location")
error_message = "Request failed due to a Permanent Redirect."
if location:
error_message += f" Please change URL to: {location}"
else:
error_message = f"Request failed with status {self.status_code}: {self.body}"
raise HttpResponseError(error_message, status_code=self.status_code)


class Responses(object):
Expand Down

0 comments on commit 723c7c9

Please sign in to comment.