The error of invalid --jq query is difficult to know what's wrong with the query. As a gojq library maintainer, I was wondering whether the library should return pretty error or not, but since the query input is given by library user, returning an error with offset is enough as a library, just like json.SyntaxError. In the release v0.12.15, I decided to export gojq.ParseError, which has the offset position in the query. This PR improves the parsing error message to report that position in fancy style. It also improves handling of halt errors.
$ gh api /user --jq '[1,2,3,,4,5]'
unexpected token ","
$ bin/gh api /user --jq '[1,2,3,,4,5]'
failed to parse jq expression (line 1, column 8)
[1,2,3,,4,5]
^ unexpected token ","
The error of invalid
--jq
query is difficult to know what's wrong with the query. As a gojq library maintainer, I was wondering whether the library should return pretty error or not, but since the query input is given by library user, returning an error with offset is enough as a library, just likejson.SyntaxError
. In the release v0.12.15, I decided to exportgojq.ParseError
, which has the offset position in the query. This PR improves the parsing error message to report that position in fancy style. It also improves handling of halt errors.