From a12fa9333b9d58ffa38bf09d76bc2cca60a867e1 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Thu, 25 Aug 2016 12:50:05 +0300 Subject: [PATCH] [node] Throw on invalid style JSON Fixes #6143 --- platform/node/src/node_map.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 3eb9d8e53..f737ddfd8 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -740,6 +740,12 @@ NodeMap::NodeMap(v8::Local options) : map(std::make_unique(view, *this, mbgl::MapMode::Still)), async(new uv_async_t) { + view.setMapChangeCallback([&](mbgl::MapChange change) { + if (change == mbgl::MapChangeDidFailLoadingMap) { + throw std::runtime_error("Requires a map style to be a valid style JSON"); + } + }); + async->data = this; uv_async_init(uv_default_loop(), async, [](UV_ASYNC_PARAMS(h)) { reinterpret_cast(h->data)->renderFinished();