Minify: Let Express render the 500 error page

This commit is contained in:
Richard Hansen 2021-02-11 19:11:50 -05:00 committed by John McLear
parent 44e420b6c5
commit 7a003cb9e2

View file

@ -143,14 +143,7 @@ const minify = async (req, res) => {
const contentType = mime.lookup(filename); const contentType = mime.lookup(filename);
let date, exists; const [date, exists] = await statFile(filename, 3);
try {
[date, exists] = await statFile(filename, 3);
} catch (err) {
res.writeHead(500, {});
res.end();
return;
}
if (date) { if (date) {
date.setMilliseconds(0); date.setMilliseconds(0);
res.setHeader('last-modified', date.toUTCString()); res.setHeader('last-modified', date.toUTCString());
@ -173,14 +166,7 @@ const minify = async (req, res) => {
res.writeHead(200, {}); res.writeHead(200, {});
res.end(); res.end();
} else if (req.method === 'GET') { } else if (req.method === 'GET') {
let content; const content = await getFileCompressed(filename, contentType);
try {
content = await getFileCompressed(filename, contentType);
} catch (err) {
res.writeHead(500, {});
res.end();
return;
}
res.header('Content-Type', contentType); res.header('Content-Type', contentType);
res.writeHead(200, {}); res.writeHead(200, {});
res.write(content); res.write(content);