JS52 Compiler: JS::Compile returns false, but no errors reported by WarningReporter

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

JS52 Compiler: JS::Compile returns false, but no errors reported by WarningReporter

Kent Williams
Trying to do something rather complex (*cough* TypeScript *cough*) and
having trouble diagnosing the problem.  The compile fails but I'm not
getting any error messages via the handler I set using
JS::SetWarningReporter.

Is there something I'm missing here?

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: JS52 Compiler: JS::Compile returns false, but no errors reported by WarningReporter

Boris Zbarsky
On 12/20/17 12:31 PM, Kent Williams wrote:
> Trying to do something rather complex (*cough* TypeScript *cough*) and
> having trouble diagnosing the problem.  The compile fails but I'm not
> getting any error messages via the handler I set using
> JS::SetWarningReporter.
>
> Is there something I'm missing here?

JS::SetWarningReporter sets a thing to be used for warnings, not errors.

To handle errors, you should examine the pending exception on the
JSContext if a JSAPI call fails.

-Boris

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: JS52 Compiler: JS::Compile returns false, but no errors reported by WarningReporter

Jason Orendorff-2
I discovered this week that there is no good public way to print an Error
in the JSAPI. This is not ideal.

The easiest workaround is to write your own try/catch block in JavaScript
and print the various parts of the Error object in the catch block.

That's not what the JS shell does, though. The shell takes advantage of
SpiderMonkey-internal APIs, including at least `js::PrintError()`. If you'd
like to wrap that behavior up into a nice, public
JS::PrintAndClearPendingException(cx, stderr) function, I'd take that
patch. It wouldn't be hard!

-j



On Wed, Dec 20, 2017 at 12:22 PM, Boris Zbarsky <[hidden email]> wrote:

> On 12/20/17 12:31 PM, Kent Williams wrote:
>
>> Trying to do something rather complex (*cough* TypeScript *cough*) and
>> having trouble diagnosing the problem.  The compile fails but I'm not
>> getting any error messages via the handler I set using
>> JS::SetWarningReporter.
>>
>> Is there something I'm missing here?
>>
>
> JS::SetWarningReporter sets a thing to be used for warnings, not errors.
>
> To handle errors, you should examine the pending exception on the
> JSContext if a JSAPI call fails.
>
> -Boris
>
>
> _______________________________________________
> dev-tech-js-engine mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: JS52 Compiler: JS::Compile returns false, but no errors reported by WarningReporter

Kent Williams
In reply to this post by Boris Zbarsky
Yeah, OK I found a good example of grabbing the exception error message.

https://dxr.mozilla.org/mozilla-central/source/dom/file/FileReader.cpp

On 12/20/2017 12:22 PM, Boris Zbarsky wrote:

> On 12/20/17 12:31 PM, Kent Williams wrote:
>> Trying to do something rather complex (*cough* TypeScript *cough*)
>> and having trouble diagnosing the problem.  The compile fails but I'm
>> not getting any error messages via the handler I set using
>> JS::SetWarningReporter.
>>
>> Is there something I'm missing here?
>
> JS::SetWarningReporter sets a thing to be used for warnings, not errors.
>
> To handle errors, you should examine the pending exception on the
> JSContext if a JSAPI call fails.
>
> -Boris
>
> _______________________________________________
> dev-tech-js-engine mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine