Skip to content

Commit 9d6af3b

Browse files
committed
added more descriptive error message for failed range downloads.
1 parent a859e12 commit 9d6af3b

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/herbie/experimental/download.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,17 @@ def _download_remote_byte_range(
8585
response.raise_for_status()
8686

8787
if response.status_code != 206:
88-
raise Exception(
89-
f"Server doesn't support range requests (status: {response.status_code})"
88+
content_length = response.headers.get("Content-Length", "unknown")
89+
response.close()
90+
raise RuntimeError(
91+
f"Range request not honored: server returned "
92+
f"HTTP {response.status_code} "
93+
f"(Content-Length: {content_length}). "
94+
f"This can happen when a network proxy or "
95+
f"VPN strips the Range header. Try downloading "
96+
f"the full file first, then subset locally:\n"
97+
f" full_file = Herbie(...).download()\n"
98+
f" Herbie(...).download(search=...)"
9099
)
91100

92101
with open(temp_file, "wb") as f:

0 commit comments

Comments
 (0)