From 07ca2dad27c49d3a25bd88bb4ab06b158d3605bf Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 26 Sep 2012 13:02:46 +0200 Subject: [PATCH] Catch parser exceptions (it does throw!) --- lib/carto/renderer.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/carto/renderer.js b/lib/carto/renderer.js index b0810a8..4075d27 100644 --- a/lib/carto/renderer.js +++ b/lib/carto/renderer.js @@ -33,9 +33,10 @@ carto.Renderer.prototype.render = function render(m, callback) { // allows frames and effects to be maintained. env = _(env).extend({filename:s.id}); - // @TODO try/catch? - var time = +new Date(), - root = (carto.Parser(env)).parse(s.data); + var time = +new Date(); + // Parser may throw + try { root = (carto.Parser(env)).parse(s.data); } + catch (err) { callback(err, null); return; } if (env.benchmark) console.warn('Parsing time: ' + (new Date() - time) + 'ms'); return root.toList(env);