mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Keep tippecanoe's own errors from being reported as protobuf errors
A tile that fails to decode is reported with EXIT_MVT, while a tile that protozero throws on is reported with EXIT_PROTOBUF. Now that decoding failures are raised as a tippecanoe_error rather than exiting on the spot, the catch that was written for protozero's exceptions catches tippecanoe's own as well, since tippecanoe_error is a std::exception: mvt_tile::decode() throwing "Tile decompression failed" came back out as EXIT_PROTOBUF and "PBF decoding error in tile z/x/y". Catch tippecanoe_error first at the four places that wrap a decode in a try. In overzoom() and in tippecanoe-decode it can be rethrown for main() to report. In tile-join it can't: append_tile() runs on a worker thread, where an escaping exception would call std::terminate() instead of exiting, so report it and exit with its own status there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DuCSVGssWNUCpVEE8Yp5HT
This commit is contained in:
@@ -8,6 +8,11 @@
|
|||||||
before. Along the way this fixes a leaked `z_stream` when `compress()`
|
before. Along the way this fixes a leaked `z_stream` when `compress()`
|
||||||
failed and two `exit()` calls that could run from a destructor or from
|
failed and two `exit()` calls that could run from a destructor or from
|
||||||
`mvt_value`'s hash function.
|
`mvt_value`'s hash function.
|
||||||
|
* Keep reporting a tile that fails to decode as `EXIT_MVT`, and report why.
|
||||||
|
Now that decoding failures throw, the `catch` meant for protozero's
|
||||||
|
exceptions was catching tippecanoe's own as well, replacing their exit
|
||||||
|
status and message with `EXIT_PROTOBUF` and a generic "PBF decoding
|
||||||
|
error".
|
||||||
* Add `--drop-by-attribute-as-needed=`*attribute* to drop the features with
|
* Add `--drop-by-attribute-as-needed=`*attribute* to drop the features with
|
||||||
the lowest values of a numeric attribute from oversized tiles, and
|
the lowest values of a numeric attribute from oversized tiles, and
|
||||||
`--drop-by-attribute-order=desc` to drop the highest values instead.
|
`--drop-by-attribute-order=desc` to drop the highest values instead.
|
||||||
|
|||||||
@@ -1230,6 +1230,10 @@ std::string overzoom(std::vector<input_tile> const &tiles, int nz, int nx, int n
|
|||||||
if (!tile.decode(t.tile, was_compressed)) {
|
if (!tile.decode(t.tile, was_compressed)) {
|
||||||
throw_tippecanoe_error(EXIT_MVT, "Couldn't parse tile %d/%u/%u", t.z, t.x, t.y);
|
throw_tippecanoe_error(EXIT_MVT, "Couldn't parse tile %d/%u/%u", t.z, t.x, t.y);
|
||||||
}
|
}
|
||||||
|
} catch (tippecanoe_error &e) {
|
||||||
|
// a tippecanoe_error is a std::exception, so it would
|
||||||
|
// otherwise be caught below and reattributed to protobuf
|
||||||
|
throw;
|
||||||
} catch (std::exception const &e) {
|
} catch (std::exception const &e) {
|
||||||
throw_tippecanoe_error(EXIT_PROTOBUF, "PBF decoding error in tile %d/%u/%u", t.z, t.x, t.y);
|
throw_tippecanoe_error(EXIT_PROTOBUF, "PBF decoding error in tile %d/%u/%u", t.z, t.x, t.y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,10 @@ void handle(std::string message, int z, unsigned x, unsigned y, std::set<std::st
|
|||||||
fprintf(stderr, "Couldn't parse tile %d/%u/%u\n", z, x, y);
|
fprintf(stderr, "Couldn't parse tile %d/%u/%u\n", z, x, y);
|
||||||
exit(EXIT_MVT);
|
exit(EXIT_MVT);
|
||||||
}
|
}
|
||||||
|
} catch (tippecanoe_error &e) {
|
||||||
|
// a tippecanoe_error is a std::exception, so it would
|
||||||
|
// otherwise be caught below and reattributed to protobuf
|
||||||
|
throw;
|
||||||
} catch (std::exception const &e) {
|
} catch (std::exception const &e) {
|
||||||
fprintf(stderr, "PBF decoding error in tile %d/%u/%u\n", z, x, y);
|
fprintf(stderr, "PBF decoding error in tile %d/%u/%u\n", z, x, y);
|
||||||
exit(EXIT_PROTOBUF);
|
exit(EXIT_PROTOBUF);
|
||||||
|
|||||||
@@ -108,6 +108,12 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
|||||||
fprintf(stderr, "Couldn't decompress tile %d/%u/%u\n", z, x, y);
|
fprintf(stderr, "Couldn't decompress tile %d/%u/%u\n", z, x, y);
|
||||||
exit(EXIT_MVT);
|
exit(EXIT_MVT);
|
||||||
}
|
}
|
||||||
|
} catch (tippecanoe_error &e) {
|
||||||
|
// a tippecanoe_error is a std::exception, so without this it
|
||||||
|
// would be caught below and reattributed to protobuf. It can't
|
||||||
|
// be rethrown either, since this runs on a worker thread.
|
||||||
|
fprintf(stderr, "%s\n", e.what());
|
||||||
|
exit(e.exit_code);
|
||||||
} catch (std::exception const &e) {
|
} catch (std::exception const &e) {
|
||||||
fprintf(stderr, "PBF decoding error in tile %d/%u/%u\n", z, x, y);
|
fprintf(stderr, "PBF decoding error in tile %d/%u/%u\n", z, x, y);
|
||||||
exit(EXIT_MVT);
|
exit(EXIT_MVT);
|
||||||
@@ -749,6 +755,11 @@ struct tileset_reader {
|
|||||||
fprintf(stderr, "Couldn't parse tile %lld/%lld/%lld\n", tile.z, tile.x, tile.y);
|
fprintf(stderr, "Couldn't parse tile %lld/%lld/%lld\n", tile.z, tile.x, tile.y);
|
||||||
exit(EXIT_MVT);
|
exit(EXIT_MVT);
|
||||||
}
|
}
|
||||||
|
} catch (tippecanoe_error &e) {
|
||||||
|
// a tippecanoe_error is a std::exception, so without this
|
||||||
|
// it would be caught below and reattributed to protobuf
|
||||||
|
fprintf(stderr, "%s\n", e.what());
|
||||||
|
exit(e.exit_code);
|
||||||
} catch (std::exception const &e) {
|
} catch (std::exception const &e) {
|
||||||
fprintf(stderr, "PBF decoding error in tile %lld/%lld/%lld\n", tile.z, tile.x, tile.y);
|
fprintf(stderr, "PBF decoding error in tile %lld/%lld/%lld\n", tile.z, tile.x, tile.y);
|
||||||
exit(EXIT_PROTOBUF);
|
exit(EXIT_PROTOBUF);
|
||||||
|
|||||||
Reference in New Issue
Block a user