Skip to content

Commit

Permalink
Raise with more info on 416 invalid range (#2449)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wauplin authored Aug 14, 2024
1 parent 09b4f4b commit dfd73c0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/huggingface_hub/utils/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None)
)
raise HfHubHTTPError(message, response=response) from e

elif response.status_code == 416:
range_header = response.request.headers.get("Range")
message = f"{e}. Requested range: {range_header}. Content-Range: {response.headers.get('Content-Range')}."
raise HfHubHTTPError(message, response=response) from e

# Convert `HTTPError` into a `HfHubHTTPError` to display request information
# as well (request id and/or server error message)
raise HfHubHTTPError(str(e), response=response) from e
Expand Down

0 comments on commit dfd73c0

Please sign in to comment.