From d0c1400b1618f6d84a35c59682dc63c4890693b9 Mon Sep 17 00:00:00 2001 From: Norris Boyd Date: Wed, 18 Jul 2007 15:08:38 +0000 Subject: [PATCH] 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.) Patch from Bob Jervis --- src/org/mozilla/javascript/ScriptRuntime.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/org/mozilla/javascript/ScriptRuntime.java b/src/org/mozilla/javascript/ScriptRuntime.java index 3bce32a40a..b255dc8ab3 100644 --- a/src/org/mozilla/javascript/ScriptRuntime.java +++ b/src/org/mozilla/javascript/ScriptRuntime.java @@ -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); }