fix: improve error handling for file retrieval in AwsS3Storage (#12002)

Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
-LAN- 2024-12-23 16:28:54 +08:00 committed by GitHub
parent ef95b1268e
commit c4091c4c66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -67,7 +67,9 @@ class AwsS3Storage(BaseStorage):
yield from response["Body"].iter_chunks()
except ClientError as ex:
if ex.response["Error"]["Code"] == "NoSuchKey":
raise FileNotFoundError("File not found")
raise FileNotFoundError("file not found")
elif "reached max retries" in str(ex):
raise ValueError("please do not request the same file too frequently")
else:
raise