1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

error(x) should not tostring its arg; fix #466

This commit is contained in:
Nicolas Williams
2014-07-07 22:26:53 -05:00
parent 824f7df404
commit a68958e5dc
2 changed files with 6 additions and 2 deletions

@ -781,7 +781,6 @@ static jv f_type(jv input) {
static jv f_error(jv input, jv msg) {
jv_free(input);
msg = f_tostring(msg);
return jv_invalid_with_msg(msg);
}

7
main.c

@ -127,7 +127,12 @@ static int process(jq_state *jq, jv value, int flags) {
if (jv_invalid_has_msg(jv_copy(result))) {
// Uncaught jq exception
jv msg = jv_invalid_get_msg(jv_copy(result));
fprintf(stderr, "jq: error: %s\n", jv_string_value(msg));
if (jv_get_kind(msg) == JV_KIND_STRING) {
fprintf(stderr, "jq: error: %s\n", jv_string_value(msg));
} else {
msg = jv_dump_string(msg, 0);
fprintf(stderr, "jq: error (not a string): %s\n", jv_string_value(msg));
}
jv_free(msg);
}
jv_free(result);