From a1afec9e1759b0fdb256d41d429161cc15ecf500 Mon Sep 17 00:00:00 2001 From: Lucain Date: Tue, 6 Feb 2024 18:45:20 +0100 Subject: [PATCH] Explicit server error on gated model (#28894) --- src/transformers/utils/hub.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/transformers/utils/hub.py b/src/transformers/utils/hub.py index edc6fb48fb..3aa452cf27 100644 --- a/src/transformers/utils/hub.py +++ b/src/transformers/utils/hub.py @@ -414,9 +414,8 @@ def cached_file( if resolved_file is not None or not _raise_exceptions_for_gated_repo: return resolved_file raise EnvironmentError( - "You are trying to access a gated repo.\nMake sure to request access at " - f"https://huggingface.co/{path_or_repo_id} and pass a token having permission to this repo either " - "by logging in with `huggingface-cli login` or by passing `token=`." + "You are trying to access a gated repo.\nMake sure to have access to it at " + f"https://huggingface.co/{path_or_repo_id}.\n{str(e)}" ) from e except RepositoryNotFoundError as e: raise EnvironmentError(