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

This commit is contained in:
Nicolas Williams committed 2014-07-07 22:26:53 -05:00
1 parent 824f7df404
commit a68958e5dc
2 files changed
+6 -2

No files matched your search

-1
View File
@@ -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);
}
+6 -1
View File
@@ -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);