From 9dc939b73a7308b611045681657d61df471af48a Mon Sep 17 00:00:00 2001 From: Jack Allnutt Date: Sat, 24 Sep 2011 23:00:47 +0100 Subject: [PATCH] Wrap the jade.compile function in a try...catch block --- node/app.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/node/app.js b/node/app.js index 6afe590..57d1928 100644 --- a/node/app.js +++ b/node/app.js @@ -617,15 +617,19 @@ this.httpHandler = function (request, response) { fs.readFile(__dirname + '/client/index.html.jade', 'utf8', function (err, str) { var html, hash2; if (!err) { - html = kiwi.jade.compile(str)({ "touchscreen": touchscreen, "debug": debug, "secure": secure, "server_set": server_set, "server": server, "nick": nick, "agent": agent, "config": kiwi.config }); - hash2 = crypto.createHash('md5').update(html).digest('base64'); - kiwi.cache.html[hash] = {"html": html, "hash": hash2}; - if (request.headers['if-none-match'] === hash2) { - response.statusCode = 304; - } else { - response.setHeader('Etag', hash2); - response.setHeader('Content-type', 'text/html'); - response.write(html); + try { + html = kiwi.jade.compile(str)({ "touchscreen": touchscreen, "debug": debug, "secure": secure, "server_set": server_set, "server": server, "nick": nick, "agent": agent, "config": kiwi.config }); + hash2 = crypto.createHash('md5').update(html).digest('base64'); + kiwi.cache.html[hash] = {"html": html, "hash": hash2}; + if (request.headers['if-none-match'] === hash2) { + response.statusCode = 304; + } else { + response.setHeader('Etag', hash2); + response.setHeader('Content-type', 'text/html'); + response.write(html); + } + } catch (e) { + response.statusCode = 500; } } else { response.statusCode = 500; -- 2.25.1