Closed Bug 49286 Opened 24 years ago Closed 23 years ago

try/catch within JavaScript not working as expected

Categories

(Rhino Graveyard :: Compiler, defect, P3)

x86
Windows 2000
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jlaprise, Assigned: norrisboyd)

Details

Consider the following JavaScript scenario

var myObj = new Packages.myclasses.MyClass();

try
{
  // If setting a property on this object throws an exception, the exception
  // will not be caught by the JavaScript try/catch
  myObj.prop1 = "test";

  // Exceptions from methods work fine
  myObj.setProp1( "test" );
}
catch( e ) { java.lang.System.out.println( "An Exception Occurred:  " + e ); }

On a related note, the try/catch mechanism doesn't seem to work at all when 
calling a function (containing a try/catch block) directly via the call method 
of the Function interface.  If an exception occurs within the try, it will not 
be caught; instead, a NullPointerException is propagated up to the caller.
Status: NEW → ASSIGNED
Roger, Patrick: any chance I could get some help with this one? 
Finally fixed.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Testcase added to JS test suite: 

           js/tests/ecma_3/Function/regress-49286.js

Covers this part of the report:

> On a related note, the try/catch mechanism doesn't seem to work at all when 
> calling a function (containing a try/catch block) directly via the call method 
> of the Function interface.  If an exception occurs within the try, it will not 
> be caught; instead, a NullPointerException is propagated up to the caller.


Testcase now passing in both the compiled and interpreted Rhino shells - 
jlaprise@delanotech.com: has this bug gone away for you now:

> Consider the following JavaScript scenario

> var myObj = new Packages.myclasses.MyClass();

> try
> {
>   // If setting a property on this object throws an exception, the exception
>   // will not be caught by the JavaScript try/catch

>                          etc. 
>                          etc.


If the bug is fixed for you now, you can mark this bug "Verified" 
(see option above). If it is not fixed, you can reopen it - thanks.
You need to log in before you can comment on or make changes to this bug.