Skip to content

Add ScriptRuntime:throwCustomError to make it easier to re-throw Java exceptions #176

@raimi

Description

@raimi

I maintain a largish application with lots of java/rhino-interwoven code. Luckily we have a test suite wich showed us that something broke with 1.7.6 wich still worked with 1.7R5.
I can reproduce serveral occasions of this trace:

java.lang.IllegalArgumentException: No enum constant org.mozilla.javascript.TopLevel.NativeErrors.XXX
    at java.lang.Enum.valueOf(Enum.java:236)
    at org.mozilla.javascript.TopLevel$NativeErrors.valueOf(TopLevel.java:67)
    at org.mozilla.javascript.ScriptRuntime.newCatchScope(ScriptRuntime.java:3439)
    at org.mozilla.javascript.gen...

where XXX is a custom js-class that I use like "throw new XXX()". I suspect these commits:
9320d8c
15be937
ff0ef45

Unfortunately, I cannot reproduce the problem in a simple Rhino shell. This all may be my fault, as I use dynamic scopes and re-loading of js source files. I just post here to warn others for a possible change of semantics.

The above Exception occurs with this code:

try {
 foo();
} catch (e) { }

...when foo() throws one of my XXX. Somehow it is an EcmaError here: https://github.com/mozilla/rhino/blob/master/src/org/mozilla/javascript/ScriptRuntime.java#L3436 ...but that does not work out.

Does this ring a bell for somebody?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions