|
7 | 7 | from tqdm.contrib.concurrent import thread_map |
8 | 8 |
|
9 | 9 | from . import constants |
10 | | -from .errors import GatedRepoError, LocalEntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError |
| 10 | +from .errors import ( |
| 11 | + GatedRepoError, |
| 12 | + HfHubHTTPError, |
| 13 | + LocalEntryNotFoundError, |
| 14 | + RepositoryNotFoundError, |
| 15 | + RevisionNotFoundError, |
| 16 | +) |
11 | 17 | from .file_download import REGEX_COMMIT_HASH, hf_hub_download, repo_folder_name |
12 | 18 | from .hf_api import DatasetInfo, HfApi, ModelInfo, SpaceInfo |
13 | 19 | from .utils import OfflineModeIsEnabled, filter_repo_objects, logging, validate_hf_hub_args |
@@ -228,8 +234,10 @@ def snapshot_download( |
228 | 234 | "outgoing traffic has been disabled. To enable repo look-ups and downloads online, set " |
229 | 235 | "'HF_HUB_OFFLINE=0' as environment variable." |
230 | 236 | ) from api_call_error |
231 | | - elif isinstance(api_call_error, RepositoryNotFoundError) or isinstance(api_call_error, GatedRepoError): |
232 | | - # Repo not found => let's raise the actual error |
| 237 | + elif isinstance(api_call_error, (RepositoryNotFoundError, GatedRepoError)) or ( |
| 238 | + isinstance(api_call_error, HfHubHTTPError) and api_call_error.response.status_code == 401 |
| 239 | + ): |
| 240 | + # Repo not found, gated, or specific authentication error => let's raise the actual error |
233 | 241 | raise api_call_error |
234 | 242 | else: |
235 | 243 | # Otherwise: most likely a connection issue or Hub downtime => let's warn the user |
|
0 commit comments