Skip to content

Commit

Permalink
Add special Rhino object __exception__ defined in the catch
Browse files Browse the repository at this point in the history
scope that can be used to retrieve the Java exception associated
with the JavaScript exception (to get stack trace info, etc.)
Patch from Bob Jervis <[email protected]>
  • Loading branch information
norrisboyd committed Jul 18, 2007
1 parent 2410b9e commit d0c1400
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/org/mozilla/javascript/ScriptRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -3098,11 +3098,18 @@ public static Scriptable newCatchScope(Throwable t,
obj = errorObject;
}


NativeObject catchScopeObject = new NativeObject();
// See ECMA 12.4
catchScopeObject.defineProperty(
exceptionName, obj, ScriptableObject.PERMANENT);

// Add special Rhino object __exception__ defined in the catch
// scope that can be used to retrieve the Java exception associated
// with the JavaScript exception (to get stack trace info, etc.)
catchScopeObject.defineProperty(
"__exception__", Context.javaToJS(t, catchScopeObject),
ScriptableObject.PERMANENT|ScriptableObject.DONTENUM);

if (cacheObj) {
catchScopeObject.associateValue(t, obj);
}
Expand Down

0 comments on commit d0c1400

Please sign in to comment.