Catch exceptions when parsing tile PBFs
Also improved the error message and updated the test case.
This commit is contained in:
committed by
John Firebaugh
parent
3670a78569
commit
d30fce5f7d
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -159,7 +159,7 @@ TEST_P(ResourceLoading, RequestWithCorruptedData) {
|
||||
message << "Failed to parse ";
|
||||
|
||||
if (param == "vector.pbf") {
|
||||
message << "\\[15\\/1638(3|4)\\/1638(3|4)\\]\\: pbf unknown field type exception";
|
||||
message << "\\[1(5|6)\\/1638(3|4)\\/1638(3|4)\\]\\: pbf unknown field type exception";
|
||||
} else {
|
||||
message << "\\[test\\/fixtures\\/resources\\/" << param << "\\]";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user