From f83e4d66ed2b6a7f7f8939e2eb63d262387e9374 Mon Sep 17 00:00:00 2001 From: Sheogorath Date: Mon, 23 Nov 2020 13:59:50 +0100 Subject: Rework error messages for image uploads This patch reworks the error messages for image uploads to make more sense. Instead of using the current `formidable error` for everything, all custom error detection now provide the (hopefully) more useful `Image Upload error` prefix for error messages. Signed-off-by: Christoph Kern --- lib/web/imageRouter/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/web/imageRouter/index.js b/lib/web/imageRouter/index.js index f456fd30..b6ace4a6 100644 --- a/lib/web/imageRouter/index.js +++ b/lib/web/imageRouter/index.js @@ -21,16 +21,16 @@ imageRouter.post('/uploadimage', function (req, res) { form.parse(req, function (err, fields, files) { if (err) { - logger.error(`formidable error: ${err}`) + logger.error(`Image upload error: formidable error: ${err}`) return errors.errorForbidden(res) } else if (!req.isAuthenticated() && !config.allowAnonymous && !config.allowAnonymousEdits) { - logger.error(`formidable error: Anonymous edits and therefore uploads are not allowed)`) + logger.error(`Image upload error: Anonymous edits and therefore uploads are not allowed)`) return errors.errorForbidden(res) } else if (!files.image || !files.image.path) { - logger.error(`formidable error: Upload didn't contain file)`) + logger.error(`Image upload error: Upload didn't contain file)`) return errors.errorBadRequest(res) } else if (!config.allowedUploadMimeTypes.includes(files.image.type)) { - logger.error(`formidable error: MIME-type "${files.image.type}" of uploaded file not allowed, only "${config.allowedUploadMimeTypes.join(', ')}" are allowed)`) + logger.error(`Image upload error: MIME-type "${files.image.type}" of uploaded file not allowed, only "${config.allowedUploadMimeTypes.join(', ')}" are allowed)`) return errors.errorBadRequest(res) } else { logger.debug(`SERVER received uploadimage: ${JSON.stringify(files.image)}`) -- cgit v1.2.3