From ece3eb3b0e8127a1871064483844f3287efdd269 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 3 Jan 2013 13:20:49 -0500 Subject: [PATCH] Remove throw in zoom evaluation --- lib/carto/tree/zoom.js | 6 +++--- test/errorhandling/zoommax.mml | 15 +++++++++++++++ test/errorhandling/zoommax.mss | 3 +++ test/errorhandling/zoommax.result | 1 + 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 test/errorhandling/zoommax.mml create mode 100644 test/errorhandling/zoommax.mss create mode 100644 test/errorhandling/zoommax.result diff --git a/lib/carto/tree/zoom.js b/lib/carto/tree/zoom.js index 3aa7c38..b20199d 100644 --- a/lib/carto/tree/zoom.js +++ b/lib/carto/tree/zoom.js @@ -21,11 +21,11 @@ tree.Zoom.prototype.eval = function(env) { zoom = 0; if (value > tree.Zoom.maxZoom || value < 0) { - throw { + env.error({ message: 'Only zoom levels between 0 and ' + tree.Zoom.maxZoom + ' supported.', - index: index - }; + index: this.index + }); } switch (this.op) { diff --git a/test/errorhandling/zoommax.mml b/test/errorhandling/zoommax.mml new file mode 100644 index 0000000..5cae361 --- /dev/null +++ b/test/errorhandling/zoommax.mml @@ -0,0 +1,15 @@ +{ + "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", + "Stylesheet": [ + "zoommax.mss" + ], + "Layer": [{ + "id": "world", + "name": "world", + "srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over", + "Datasource": { + "file": "http://tilemill-data.s3.amazonaws.com/test_data/shape_demo.zip", + "type": "shape" + } + }] +} diff --git a/test/errorhandling/zoommax.mss b/test/errorhandling/zoommax.mss new file mode 100644 index 0000000..5c23489 --- /dev/null +++ b/test/errorhandling/zoommax.mss @@ -0,0 +1,3 @@ +#world[zoom > 40] { + polygon-fill: #fff; +} diff --git a/test/errorhandling/zoommax.result b/test/errorhandling/zoommax.result new file mode 100644 index 0000000..23e7cbc --- /dev/null +++ b/test/errorhandling/zoommax.result @@ -0,0 +1 @@ +zoommax.mss:1:6 Only zoom levels between 0 and 22 supported.