mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:07:34 +00:00
gron: Handle invalid input gracefully
Print an error and return 1, instead of asserting.
This commit is contained in:
parent
d09fb8f599
commit
0b2bf3d73a
1 changed files with 9 additions and 1 deletions
|
@ -70,7 +70,15 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto file_contents = file->read_all();
|
auto file_contents = file->read_all();
|
||||||
auto json = JsonValue::from_string(file_contents);
|
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) {
|
if (use_color) {
|
||||||
color_name = "\033[33;1m";
|
color_name = "\033[33;1m";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue