Print offending object in runtime error messages
When reporting an error to the user, add information about the offending
object/value (possibly truncated).
The goal is to give a user some context regarding which input object
caused the runtime error.
Examples:
$ echo '"hello"' | ./jq '-.'
jq: error: string ("hello") cannot be negated
$ echo '"very-long-string"' | ./jq '-.'
jq: error: string ("very-long-...) cannot be negated
$ echo '["1",2]' | ./jq '.|join(",")'
jq: error: string (",") and number (2) cannot be added
$ echo '["1","2",{"a":{"b":{"c":33}}}]' | ./jq '.|join(",")'
jq: error: string (",") and object ({"a":{"b":{...) cannot be added
$ echo '{"a":{"b":{"c":33}}}' | ./jq '.a | @tsv'
jq: error: object ({"b":{"c":33}}) cannot be tsv-formatted, only array
(Fix #754)
This commit is contained in:
1 parent
a50e548cc5
commit
7b6a018dff
5 files changed
+44
-6
No files matched your search
@@ -1173,3 +1173,15 @@ import "test_bind_order" as check; check::check
|
||||
null
|
||||
true
|
||||
|
||||
try -. catch .
|
||||
"very-long-string"
|
||||
"string (\"very-long-...) cannot be negated"
|
||||
|
||||
try join(",") catch .
|
||||
["1",2]
|
||||
"string (\",\") and number (2) cannot be added"
|
||||
|
||||
try join(",") catch .
|
||||
["1","2",{"a":{"b":{"c":33}}}]
|
||||
"string (\",\") and object ({\"a\":{\"b\":{...) cannot be added"
|
||||
|
||||
Reference in new issue
Block a user