From 9f699b4ed028796f37f2dc55218d432612354414 Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Tue, 29 Nov 2011 16:55:48 +0100 Subject: Catch exception thrown by JSON.parse --- model_fs.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'model_fs.js') diff --git a/model_fs.js b/model_fs.js index 14cb4b5..3e2af12 100644 --- a/model_fs.js +++ b/model_fs.js @@ -87,7 +87,11 @@ exports.rebuildFiles = function() { var collectEvents = function(slideset) { fs.readFile(path.join(__dirname, configuration.dir, slideset, configuration.events), function(err, data) { if(err) { throw err; } - var events = JSON.parse(data.toString()); + try { + var events = JSON.parse(data.toString()); + } catch(e) { + throw err; + } if(events['type'] == 'text') { setEvents(slideset, events['events'], function(err) { if(err) { throw err; } -- cgit v1.2.1