From 6c55552b0a8f0ec8c04e1fd03bda10efea6c0c37 Mon Sep 17 00:00:00 2001 From: Zirak Date: Wed, 3 Apr 2019 11:50:39 +0300 Subject: [PATCH] Include source name in invalid GeoJSON error When supplying invalid data to a GeoJSON source, include the source name in the error message for easier debugging. --- src/source/geojson_worker_source.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/source/geojson_worker_source.js b/src/source/geojson_worker_source.js index 5add854fd0e..00fc790efa8 100644 --- a/src/source/geojson_worker_source.js +++ b/src/source/geojson_worker_source.js @@ -167,7 +167,7 @@ class GeoJSONWorkerSource extends VectorTileWorkerSource { if (err || !data) { return callback(err); } else if (typeof data !== 'object') { - return callback(new Error("Input data is not a valid GeoJSON object.")); + return callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`)); } else { rewind(data, true); @@ -267,10 +267,10 @@ class GeoJSONWorkerSource extends VectorTileWorkerSource { try { return callback(null, JSON.parse(params.data)); } catch (e) { - return callback(new Error("Input data is not a valid GeoJSON object.")); + return callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`)); } } else { - return callback(new Error("Input data is not a valid GeoJSON object.")); + return callback(new Error(`Input data given to '${params.source}' is not a valid GeoJSON object.`)); } }