From 9396a9ab49c592e31b06a3fc699812008813aea8 Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Wed, 6 Jun 2018 00:40:33 +0700 Subject: [PATCH] Updated uploadController.js Better snekfetch's error handling, probably. --- controllers/uploadController.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/uploadController.js b/controllers/uploadController.js index bbb710b..36ae1da 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -216,7 +216,8 @@ uploadsController.actuallyUploadByUrl = async (req, res, user, albumid) => { } const head = await snekfetch.head(url) - .catch(erred) + .catch(error => error) + if (head.status !== 200) { return erred(head.toString()) } if (!head) { return } const size = parseInt(head.headers['content-length']) @@ -228,7 +229,8 @@ uploadsController.actuallyUploadByUrl = async (req, res, user, albumid) => { } const download = await snekfetch.get(url) - .catch(erred) + .catch(error => error) + if (download.status !== 200) { return erred(download.toString()) } if (!download) { return } const length = uploadsController.getFileNameLength(req)