fiatjaf / jq-web

jq in the browser with emscripten.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot access full jq error details

mandatoryprogrammer opened this issue · comments

Hello,

I recently took a look at this library and it appears that the error details are stripped a bit before being passed to the Promise.reject?

The error I get is a string of Error: 1 compile error when the error I want is the verbose error that jq would normally provide:

jq: error: syntax error, unexpected '$', expecting IDENT or __loc__ (Unix shell quoting issues?) at <top-level>, line 1:
$$ 
jq: 1 compile error

I can see that the full error is actually returned by the WASM:
Screen Shot 2019-11-02 at 5 54 44 PM

But it appears its stripped in the source maybe here?:

jq-web/post.js

Line 30 in a9b0a2d

if (errString.indexOf(':') > -1) {

With the error being stripped down it makes it pretty painful to debug issues with the JQ syntax. In my specific case users are providing them so I'd like to give somewhat helpful feedback about what they can change instead of a vague compile error string.

I think fixing this should be easy? Just don't split on the :? Let me know if I'm reading this correctly.

I've tried to be fancy here: you can access the full output at err.stack. err.message will continue as the same uncomplete unhelpful error message thing. Hopefully this solves the issue for you.

Sick, thanks! Would you mind pushing the update to npm?

Ok, forgot about that.