Skip to content

Commit 87ccc5d

Browse files
authored
Merge pull request #69 from reginbald/patch-1
Return 404 if image is not found
2 parents 3d6d826 + 5a77e05 commit 87ccc5d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

functions/image-processing/index.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export const handler = async (event) => {
3333
originalImageBody = getOriginalImageCommandOutput.Body.transformToByteArray();
3434
contentType = getOriginalImageCommandOutput.ContentType;
3535
} catch (error) {
36+
if (error.name === "NoSuchKey") {
37+
return sendError(404, "The requested image does not exist", error);
38+
}
3639
return sendError(500, 'Error downloading original image', error);
3740
}
3841
let transformedImage = Sharp(await originalImageBody, { failOn: 'none', animated: true });

0 commit comments

Comments
 (0)