Merge pull request #249 from mapbox/decode-check-error

Fail gracefully if input to tippecanoe-decode isn't a vector tile
This commit is contained in:
Eric Fischer 2016-05-25 11:53:41 -07:00
commit b5c5d9dad6

View File

@ -11,6 +11,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <protozero/pbf_reader.hpp>
#include "mvt.hpp" #include "mvt.hpp"
#include "projection.hpp" #include "projection.hpp"
#include "geometry.hpp" #include "geometry.hpp"
@ -49,8 +50,13 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe) {
int within = 0; int within = 0;
mvt_tile tile; mvt_tile tile;
if (!tile.decode(message)) { try {
fprintf(stderr, "Couldn't parse tile %d/%u/%u\n", z, x, y); if (!tile.decode(message)) {
fprintf(stderr, "Couldn't parse tile %d/%u/%u\n", z, x, y);
exit(EXIT_FAILURE);
}
} catch (protozero::unknown_pbf_wire_type_exception e) {
fprintf(stderr, "PBF decoding error in tile %d/%u/%u\n", z, x, y);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }