Hi Jesse.

On 6 apr 2007, at 10.35, Jesse Thompson wrote:

Am I approaching this the wrong way, or is this perhaps something to report
in rt?

It looks like when I bind a class and throw an error (such as a die()
statement or a failed DB connect) from within a static or object method, it
bubbles beautifully through JS as an exception.

However when I bind a class and register some perl sub as a *constructor*, any dies or errors from there seem to make the constructor abort silently
instead.

Yes, this seems to be a bug. I think the problem lies within this piece of code from PJS_construct_perl_object (in JavaScript.xs)

    if (SvROK(pcls->cons)) {
        SV *rsv;
        SV *pkg = newSVpv(pcls->pkg, 0);
        perl_call_sv_with_jsvals_rsv(cx, obj,
                                     pcls->cons, pkg,
                                     argc, argv, &rsv);

        SvREFCNT_inc(rsv);

        JS_SetPrivate(cx, obj, (void *) rsv);
    }

    return JS_TRUE;

perl_call_sv_with_jsvals_rsv returns JS_FALSE if it throws an exception so we should also return JS_FALSE.

Please report this as an bug in RT and I'll fix it in the next release.

Thanks,
Claes

Reply via email to