From 2a507eea9ed71c145e794cb0b46721f0dd19f07b Mon Sep 17 00:00:00 2001 From: Jayden Seric Date: Thu, 19 Jul 2018 16:51:08 +1000 Subject: [PATCH] Add missing error HTTP status codes. --- src/middleware.mjs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/middleware.mjs b/src/middleware.mjs index 325293f..63b27d9 100644 --- a/src/middleware.mjs +++ b/src/middleware.mjs @@ -136,7 +136,8 @@ export const processRequest = ( stream.on('limit', () => capacitor.destroy( new MaxFileSizeUploadError( - 'File truncated as it exceeds the size limit.' + 'File truncated as it exceeds the size limit.', + 413 ) ) ) @@ -175,7 +176,9 @@ export const processRequest = ( }) parser.once('filesLimit', () => { - exit(new MaxFilesUploadError(`${maxFiles} max file uploads exceeded.`)) + exit( + new MaxFilesUploadError(`${maxFiles} max file uploads exceeded.`, 413) + ) }) parser.once('finish', () => { @@ -186,7 +189,7 @@ export const processRequest = ( for (const upload of map.values()) if (!upload.file) upload.reject( - new FileMissingUploadError('File missing in the request.') + new FileMissingUploadError('File missing in the request.', 400) ) })