Skip to content

Commit

Permalink
Improve "can't happen" error messages in expression evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Nov 28, 2024
1 parent dcc616d commit 9ca4e5c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static std::string mvt_value_to_string(mvt_value const &one, bool &fail, std::ve
return "";
case mvt_no_such_key:
default:
fprintf(stderr, "unhandled mvt_type %d\n", one.type);
fprintf(stderr, "unhandled mvt_type %d (%s)\n", one.type, one.toString().c_str());
exit(EXIT_IMPOSSIBLE);
}
}
Expand Down Expand Up @@ -107,7 +107,7 @@ int compare_fsl(mvt_value const &one, json_object *two, bool &fail, std::vector<
fail = true; // null op number => null
return 0;
default:
fprintf(stderr, "unhandled mvt_type %d\n", one.type);
fprintf(stderr, "unhandled mvt_type %d comparing %s to %s\n", one.type, one.toString().c_str(), json_stringify(two));
exit(EXIT_IMPOSSIBLE);
}

Expand Down Expand Up @@ -161,15 +161,15 @@ int compare_fsl(mvt_value const &one, json_object *two, bool &fail, std::vector<

case mvt_no_such_key:
default:
fprintf(stderr, "unhandled mvt_type %d\n", one.type);
fprintf(stderr, "unhandled mvt_type %d comparing %s to %s\n", one.type, one.toString().c_str(), json_stringify(two));
exit(EXIT_IMPOSSIBLE);
}

bool rhs = two->type == JSON_TRUE;
return lhs - rhs;
}

fprintf(stderr, "unhandled JSON type %d\n", two->type);
fprintf(stderr, "unhandled JSON type %d comparing %s to %s\n", two->type, one.toString().c_str(), json_stringify(two));
exit(EXIT_IMPOSSIBLE);
}

Expand Down Expand Up @@ -212,7 +212,7 @@ int compare(mvt_value const &one, json_object *two, bool &fail) {
break;
case mvt_no_such_key:
default:
fprintf(stderr, "Internal error: bad mvt type %d\n", one.type);
fprintf(stderr, "Internal error: bad mvt type %d (%s)\n", one.type, one.toString().c_str());
exit(EXIT_IMPOSSIBLE);
}

Expand Down Expand Up @@ -248,7 +248,7 @@ int compare(mvt_value const &one, json_object *two, bool &fail) {
break;
}

fprintf(stderr, "Internal error: bad mvt type %d\n", one.type);
fprintf(stderr, "Internal error: bad mvt type %d (%s)\n", one.type, one.toString().c_str());
exit(EXIT_IMPOSSIBLE);
}

Expand Down Expand Up @@ -445,7 +445,7 @@ static int eval(std::function<mvt_value(std::string const &)> feature, json_obje
return cmp <= 0;
}

fprintf(stderr, "expression fsl comparison: can't happen %s\n", f->value.array.array[1]->value.string.string);
fprintf(stderr, "expression fsl comparison: can't happen %s (%s)\n", f->value.array.array[1]->value.string.string, json_stringify(f));
exit(EXIT_IMPOSSIBLE);
}

Expand Down

0 comments on commit 9ca4e5c

Please sign in to comment.