diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-06-10 21:50:35 +0300 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-07-01 15:21:10 -0700 |
commit | d30fce5f7dbc42b46e020a9d7b45347473097d6d (patch) | |
tree | 2c49521b37ca5111e31179388aab8a55b4a01ef9 /src | |
parent | 3670a78569bd9f7f92b768a9c761b4d8d4b278e3 (diff) | |
download | qtlocation-mapboxgl-d30fce5f7dbc42b46e020a9d7b45347473097d6d.tar.gz |
Catch exceptions when parsing tile PBFs
Also improved the error message and updated the test case.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/vector_tile_data.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/util/worker.cpp | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/mbgl/map/vector_tile_data.cpp b/src/mbgl/map/vector_tile_data.cpp index be26408492..bf4c0f5814 100644 --- a/src/mbgl/map/vector_tile_data.cpp +++ b/src/mbgl/map/vector_tile_data.cpp @@ -76,7 +76,9 @@ bool VectorTileData::reparse(Worker&, std::function<void()> callback) { if (result.is<State>()) { state = result.get<State>(); } else { - error = result.get<std::string>(); + std::stringstream message; + message << "Failed to parse [" << std::string(id) << "]: " << result.get<std::string>(); + error = message.str(); state = State::obsolete; } diff --git a/src/mbgl/util/worker.cpp b/src/mbgl/util/worker.cpp index 74408a7daf..0d83bc49f4 100644 --- a/src/mbgl/util/worker.cpp +++ b/src/mbgl/util/worker.cpp @@ -25,8 +25,12 @@ public: } TileParseResult parseVectorTile(TileWorker* worker, std::string data) { - VectorTile vectorTile(pbf(reinterpret_cast<const unsigned char *>(data.data()), data.size())); - return worker->parse(vectorTile); + try { + pbf tilePBF(reinterpret_cast<const unsigned char *>(data.data()), data.size()); + return worker->parse(VectorTile(tilePBF)); + } catch (const std::exception& ex) { + return TileParseResult(ex.what()); + } } TileParseResult parseLiveTile(TileWorker* worker, const LiveTile* tile) { |