JS_SetErrorReporter and top-level errors

View: New views
4 Messages — Rating Filter:   Alert me  

JS_SetErrorReporter and top-level errors

by AJG-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there,

I just noticed that in some cases, the callback set with
JS_SetErrorReporter does not get called when one would expect. For
instance, if it's a top-level error, but not a syntax error, and there
is no catch block above it to trap it.

In other words, what I'm seeing is that it's possible for
JS_ExecuteScript to return false even without a single call to the
error reporter callback.

Is that by design, or might I have a bug in my code somewhere?

Has this behavior changed recently?

At any rate, if it's by design, how can I figure out what the error
was? All JS_ExecuteScript returns is JS_FALSE, which isn't a lot of
information :). I looked around, but I didn't find a JS_GetLastError
or such in the API. Any clues?

Thanks a ton!
      Al.
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Re: JS_SetErrorReporter and top-level errors

by Mike Shaver :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jul 21, 2008 at 12:12 AM, AJG <plus.ajg@...> wrote:
> In other words, what I'm seeing is that it's possible for
> JS_ExecuteScript to return false even without a single call to the
> error reporter callback.
>
> Is that by design, or might I have a bug in my code somewhere?

It can certainly happen due to a bug in your code, but if your
JS_ExecuteScript is called with JS on the stack already (such as from
a "load" method that you implement) then the error will manifest as an
exception.  Use JS_IsExceptionPending to see if that's the case, and
then you can fetch the exception value via JS_GetPendingException or
simply cause it to be reported to the error reporter via
JS_ReportPendingException.

Mike
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Parent Message unknown Re: JS_SetErrorReporter and top-level errors

by AJG-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Jul 21, 6:38 am, "Mike Shaver" <mike.sha...@...> wrote:

> On Mon, Jul 21, 2008 at 12:12 AM, AJG <plus....@...> wrote:
> > In other words, what I'm seeing is that it's possible for
> > JS_ExecuteScript to return false even without a single call to the
> > error reporter callback.
>
> > Is that by design, or might I have a bug in my code somewhere?
>
> It can certainly happen due to a bug in your code, but if your
> JS_ExecuteScript is called with JS on the stack already (such as from
> a "load" method that you implement) then the error will manifest as an
> exception.  

Ah, thank you. As a matter of fact, that was exactly the case :). The
problem happened inside nested load()-type functions.

Use JS_IsExceptionPending to see if that's the case, and
> then you can fetch the exception value via JS_GetPendingException or
> simply cause it to be reported to the error reporter via
> JS_ReportPendingException.

Ok, I'll take a look at these. Can the jsval set by
GetPendingException be stringized using something like
JS_ValueToString? Or do I have to treat it specially?

Thanks again.
       Al.


_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Re: JS_SetErrorReporter and top-level errors

by Mike Shaver :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Jul 23, 2008 at 1:11 PM, AJG <plus.ajg@...> wrote:
> Ok, I'll take a look at these. Can the jsval set by
> GetPendingException be stringized using something like
> JS_ValueToString? Or do I have to treat it specially?

It's just a value, yeah, JS_ValueToString should work fine.

Mike
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine
LightInTheBox - Buy quality products at wholesale price