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

Improve error message in case of a redirect #119

Merged
merged 1 commit into from
Mar 31, 2024
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
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
Loading