diff options
author | Assaf Gordon <assafgordon@gmail.com> | 2015-04-17 18:18:33 -0400 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2015-05-21 18:49:24 -0500 |
commit | 7b6a018dff623a4f13f6bcd52c7c56d9b4a4165f (patch) | |
tree | 9e5a63bde790eb18aed024fc6ae39b0ec05056cf /tests | |
parent | a50e548cc5313c187483bc8fb1b95e1798e8ef65 (diff) |
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)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/all.test | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/all.test b/tests/all.test index 106afaa4..950801ab 100644 --- a/tests/all.test +++ b/tests/all.test @@ -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" + |