Skip to content

Commit ed64c28

Browse files
committed
Handling thumbnail generator error when resource is not found.
1 parent 4926905 commit ed64c28

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"docker:dev:test": "docker-compose -f docker-compose.yml -f docker-compose.dev.yml run --rm -e NODE_ENV=test backend npm test",
2020
"docker:prod:run": "docker-compose -f docker-compose.yml -f docker-compose.production.yml up --build",
2121
"docker:prod:stop": "docker-compose -f docker-compose.yml -f docker-compose.production.yml down -v && docker image prune -f",
22-
"docker:prod:push": "(docker-compose -f docker-compose.yml -f docker-compose.production.yml build) && (docker tag json-patch-api-image-prod sandunwebdev/json-patch-api-image-prod:latest) && (docker push sandunwebdev/json-patch-api-image-prod:latest)"
22+
"docker:prod:push": "(docker-compose -f docker-compose.yml -f docker-compose.production.yml build) && (docker tag json-patch-api-image-prod sandunwebdev/json-patch-api-image-prod:latest) && (docker push sandunwebdev/json-patch-api-image-prod:latest)",
23+
"docker:heroku:push": "(heroku stack:set container) && (git push heroku master)"
2324
},
2425
"author": "",
2526
"license": "ISC",

routers/imageRouter/helpers/imageDownloadAndResizeUtility.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,7 @@ module.exports.downloadImageAsStream = async function downloadImageAsStream(
1212
url: imgageURL,
1313
method: "GET",
1414
responseType: "stream"
15-
})
16-
.then(response => response.data)
17-
.catch(err => {
18-
return handleCustomError({
19-
customErrType: "clientError",
20-
statusCode: 401,
21-
customErrMsg:
22-
"Error Occured While Getting Your Image. Check Your Img Link Is Valid Or Not."
23-
});
24-
});
15+
}).then(response => response.data);
2516
};
2617

2718
module.exports.downloadImageToDisk = async function downloadImageToDisk(

routers/imageRouter/imageRouterController.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ module.exports.image_thumbnailPath__POST = (req, res, next) => {
2727
*/
2828

2929
// Downloading image and piping image stream through different pipeline steps to serve resized image to user.
30-
downloadImageAsStream(imageURL)
30+
downloadImageAsStream(imageURL, next)
3131
.then(imageStream => {
3232
imageStream.pipe(imageResizer).pipe(res);
3333
})
3434
.catch(err => {
3535
return handleCustomError({
36+
next,
3637
customErrType: "clientError",
3738
statusCode: 401,
38-
customErrMsg: "Error Occured While Resizing Your Image. Try Agin."
39+
customErrMsg: `Error Occured While Fetching Your Image. Check your Image URL is Public & Online. Then Try Agin.`
3940
});
4041
});
4142

0 commit comments

Comments
 (0)