From aad9e4e8d3c08ba39d85087247f80b4f0689519f Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 27 Oct 2014 08:44:31 -0600 Subject: [PATCH 1/2] Throw instead of calling a function that throws --- src/ol/format/wktformat.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/ol/format/wktformat.js b/src/ol/format/wktformat.js index 12e220ea9c..e4dd17d239 100644 --- a/src/ol/format/wktformat.js +++ b/src/ol/format/wktformat.js @@ -602,7 +602,7 @@ ol.format.WKT.Parser.prototype.parseGeometry_ = function() { return new ctor(coordinates); } } - this.raiseError_(); + throw new Error(this.formatErrorMessage_()); }; @@ -622,7 +622,7 @@ ol.format.WKT.Parser.prototype.parseGeometryCollectionText_ = function() { } else if (this.isEmptyGeometry_()) { return []; } - this.raiseError_(); + throw new Error(this.formatErrorMessage_()); }; @@ -639,7 +639,7 @@ ol.format.WKT.Parser.prototype.parsePointText_ = function() { } else if (this.isEmptyGeometry_()) { return null; } - this.raiseError_(); + throw new Error(this.formatErrorMessage_()); }; @@ -656,7 +656,7 @@ ol.format.WKT.Parser.prototype.parseLineStringText_ = function() { } else if (this.isEmptyGeometry_()) { return []; } - this.raiseError_(); + throw new Error(this.formatErrorMessage_()); }; @@ -673,7 +673,7 @@ ol.format.WKT.Parser.prototype.parsePolygonText_ = function() { } else if (this.isEmptyGeometry_()) { return []; } - this.raiseError_(); + throw new Error(this.formatErrorMessage_()); }; @@ -695,7 +695,7 @@ ol.format.WKT.Parser.prototype.parseMultiPointText_ = function() { } else if (this.isEmptyGeometry_()) { return []; } - this.raiseError_(); + throw new Error(this.formatErrorMessage_()); }; @@ -713,7 +713,7 @@ ol.format.WKT.Parser.prototype.parseMultiLineStringText_ = function() { } else if (this.isEmptyGeometry_()) { return []; } - this.raiseError_(); + throw new Error(this.formatErrorMessage_()); }; @@ -730,7 +730,7 @@ ol.format.WKT.Parser.prototype.parseMultiPolygonText_ = function() { } else if (this.isEmptyGeometry_()) { return []; } - this.raiseError_(); + throw new Error(this.formatErrorMessage_()); }; @@ -751,7 +751,7 @@ ol.format.WKT.Parser.prototype.parsePoint_ = function() { if (coordinates.length == this.dimension_) { return coordinates; } - this.raiseError_(); + throw new Error(this.formatErrorMessage_()); }; @@ -822,12 +822,13 @@ ol.format.WKT.Parser.prototype.isEmptyGeometry_ = function() { /** + * Create an error message for an unexpected token error. + * @return {string} Error message. * @private */ -ol.format.WKT.Parser.prototype.raiseError_ = function() { - throw new Error('Unexpected `' + this.token_.value + - '` at position ' + this.token_.position + - ' in `' + this.lexer_.wkt + '`'); +ol.format.WKT.Parser.prototype.formatErrorMessage_ = function() { + return 'Unexpected `' + this.token_.value + '` at position ' + + this.token_.position + ' in `' + this.lexer_.wkt + '`'; }; From 7c2e0fa627b0e2ea363fc51be0748e3d7f122f76 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 27 Oct 2014 08:45:11 -0600 Subject: [PATCH 2/2] Verbose warnings --- build.py | 1 + config/examples-all.json | 1 + config/ol.json | 1 + 3 files changed, 3 insertions(+) diff --git a/build.py b/build.py index dd012dceb4..89fa86b4ee 100755 --- a/build.py +++ b/build.py @@ -345,6 +345,7 @@ def examples_star_json(name, match): "api", "observable" ], "compilation_level": "ADVANCED", + "warning_level": "VERBOSE", "output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();", "use_types_for_optimization": True, "manage_closure_dependencies": True diff --git a/config/examples-all.json b/config/examples-all.json index f5b300e3ca..2ad36733e4 100644 --- a/config/examples-all.json +++ b/config/examples-all.json @@ -68,6 +68,7 @@ "api", "observable" ], "compilation_level": "ADVANCED", + "warning_level": "VERBOSE", "output_wrapper": "// OpenLayers 3. See http://ol3js.org/\n(function(){%output%})();", "use_types_for_optimization": true, "manage_closure_dependencies": true diff --git a/config/ol.json b/config/ol.json index 0740a4c8d5..1e86764780 100644 --- a/config/ol.json +++ b/config/ol.json @@ -58,6 +58,7 @@ "api", "observable" ], "compilation_level": "ADVANCED", + "warning_level": "VERBOSE", "output_wrapper": "(function(){%output%})();", "use_types_for_optimization": true, "manage_closure_dependencies": true