From c4a01d51ea755089401f767ad258126969615c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 10 Dec 2015 14:07:23 -0800 Subject: [PATCH] [core] don't fail on invalid inline GeoJSON data --- src/mbgl/style/style_parser.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp index 259517b0a..dd89b84e6 100644 --- a/src/mbgl/style/style_parser.cpp +++ b/src/mbgl/style/style_parser.cpp @@ -171,9 +171,16 @@ bool StyleParser::parseGeoJSONSource(Source& source, const JSVal& sourceVal) { } else if (dataVal.IsObject()) { // We need to parse dataVal as a GeoJSON object using namespace mapbox::geojsonvt; - source.info.geojsonvt = std::make_unique(Convert::convert(dataVal, 0)); + try { + source.info.geojsonvt = std::make_unique(Convert::convert(dataVal, 0)); + } catch (const std::exception& ex) { + Log::Error(Event::ParseStyle, "Failed to parse GeoJSON data: %s", ex.what()); + // Create an empty GeoJSON VT object to make sure we're not infinitely waiting for + // tiles to load. + source.info.geojsonvt = std::make_unique(std::vector{}); + } } else { - Log::Warning(Event::ParseStyle, "GeoJSON data must be a URL or an object"); + Log::Error(Event::ParseStyle, "GeoJSON data must be a URL or an object"); return false; }