Skip to content

Commit 7c7b2fd

Browse files
authored
Fix #86 -- Catch and log file not found exception (#91)
1 parent dbb3d14 commit 7c7b2fd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

s3file/middleware.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
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')
8+
59

610
class S3FileMiddleware:
711

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

0 commit comments

Comments
 (0)