1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:47:45 +00:00

gron: Handle invalid input gracefully

Print an error and return 1, instead of asserting.
This commit is contained in:
Sam Atkins 2021-06-08 15:57:56 +01:00 committed by Andreas Kling
parent d09fb8f599
commit 0b2bf3d73a

View file

@ -70,7 +70,15 @@ int main(int argc, char** argv)
auto file_contents = file->read_all();
auto json = JsonValue::from_string(file_contents);
VERIFY(json.has_value());
if (!json.has_value()) {
if (path) {
warnln("Failed to parse '{}' as JSON", path);
} else {
warnln("Failed to parse stdin as JSON");
}
return 1;
}
if (use_color) {
color_name = "\033[33;1m";