From 6a040acd07466768c1f2ea935a65e7ecdef1c7c6 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 26 Sep 2012 15:51:05 +0200 Subject: [PATCH] Catch parser exception in the correct scope --- lib/carto/renderer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/carto/renderer.js b/lib/carto/renderer.js index 5bbd2ef..14a3597 100644 --- a/lib/carto/renderer.js +++ b/lib/carto/renderer.js @@ -29,6 +29,7 @@ carto.Renderer.prototype.render = function render(m, callback) { var output = []; // Transform stylesheets into rulesets. + try { // Parser may throw var rulesets = _(m.Stylesheet).chain() .map(function(s) { // Passing the environment from stylesheet to stylesheet, @@ -36,15 +37,14 @@ carto.Renderer.prototype.render = function render(m, callback) { env = _(env).extend({filename:s.id}); var time = +new Date(); - // Parser may throw - try { root = (carto.Parser(env)).parse(s.data); } - catch (err) { callback(err, null); return; } + root = (carto.Parser(env)).parse(s.data); if (env.benchmark) console.warn('Parsing time: ' + (new Date() - time) + 'ms'); return root.toList(env); }) .flatten() .value(); + } catch (err) { callback(err, null); return; } // Iterate through layers and create styles custom-built // for each of them, and apply those styles to the layers.