Skip to content

Commit 9ec6c44

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

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

s3file/middleware.py

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

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

57

8+
logger = logging.getLogger('s3file')
9+
10+
611
class S3FileMiddleware:
712

813
def __init__(self, get_response):
@@ -22,4 +27,7 @@ def get_files_from_storage(paths):
2227
for path in paths:
2328
f = default_storage.open(path)
2429
f.name = os.path.basename(path)
25-
yield f
30+
try:
31+
yield f
32+
except ClientError:
33+
logger.exception("File not found: %s", path)

0 commit comments

Comments
 (0)