tags:

views:

19

answers:

0

Hello all,

I'm developing a XulRunner application based in Java. It's basically a controlled browser to run javascript applications, and users won't have the chance to neither reload nor enter an URL to browse. So that, I must control the javascript code being executed on the application in order to catch any javascript error. For that task I'm using the jsdiDebuggerService, the problem is that I'm being alerted for any javascript error, both catched and uncatched in code, and I only want to be alerted for uncatched ones.

What I do is something like:

public class MyClass {
    ...
    public void init ( ) {
        jsdIDebuggerService service = methodToGetJsdIDebuggerService ( );
        service.setErrorHook ( new MyErrorHook ( ) );
    }
}

public class MyErrroHook implements jsdIErrorHook {

    public boolean onError ( String errmsg,
                             String filename,
                             long linenumber,
                             long position,
                             long flags,
                             long errnum,
                             jsdIValue jsdivalue) {

        if      ( ( flags & REPORT_ERROR     ) != 0 ) handleError     ( ... );
        else if ( ( flags & REPORT_EXCEPTION ) != 0 ) handleException ( ... );
        else if ( ( flags & REPORT_STRICT    ) != 0 ) handleStrict    ( ... );
        else if ( ( flags & REPORT_WARNING   ) != 0 ) handleWarning   ( ... );
        else                                          handleUnknown   ( ... );

    }

}

On this code, I DO allways get a call to handleException, even when the error is being try/catched on the javascript code.

Is there any other service to trace JS errors? Do I need to configure the jsdIDebuggerService to do this?