Skip to content

Commit b63e002

Browse files
committed
Fix #86 -- Catch and log file not found exception
1 parent 028e16c commit b63e002

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

s3file/middleware.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import logging
12
import os
23

4+
from botocore.exceptions import ClientError
35
from django.core.files.storage import default_storage
46

7+
logger = logging.getLogger('s3file')
58

69
class S3FileMiddleware:
710

@@ -22,4 +25,7 @@ def get_files_from_storage(paths):
2225
for path in paths:
2326
f = default_storage.open(path)
2427
f.name = os.path.basename(path)
25-
yield f
28+
try:
29+
yield f
30+
except ClientError:
31+
logger.exception("File not found: %s", path)

0 commit comments

Comments
 (0)