From 572194d2bcf70e5778095d6f919ea2eb65d5283f Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 7 Dec 2006 09:27:39 +0000 Subject: [PATCH] * Simplify exception handling in invoke(), bugs in Rhino have been fixed. --- src/helma/scripting/rhino/RhinoEngine.java | 32 ++++------------------ 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/src/helma/scripting/rhino/RhinoEngine.java b/src/helma/scripting/rhino/RhinoEngine.java index fcb4d17b..1693f779 100644 --- a/src/helma/scripting/rhino/RhinoEngine.java +++ b/src/helma/scripting/rhino/RhinoEngine.java @@ -335,38 +335,18 @@ public class RhinoEngine implements ScriptingEngine { throw new TimeoutException(); } - // create and throw a ScriptingException with the right message - String msg; - if (x instanceof JavaScriptException) { - // created by javascript throw statement - msg = x.getMessage(); - } else if (x instanceof WrappedException) { + if (x instanceof WrappedException) { // wrapped java excepiton - WrappedException wx = (WrappedException) x; - Throwable wrapped = wx.getWrappedException(); - // if this is a wrapped concurrencyException, rethrow it. + Throwable wrapped = ((WrappedException) x).getWrappedException(); + // rethrow if this is a wrapped concurrency or redirect exception if (wrapped instanceof ConcurrencyException) { throw (ConcurrencyException) wrapped; - } - // also check if this is a wrapped redirect exception - if (wrapped instanceof RedirectException) { + } else if (wrapped instanceof RedirectException) { throw (RedirectException) wrapped; } - // we need to build our own message here, default implementation is broken - StringBuffer b = new StringBuffer(wrapped.toString()); - b.append(" (").append(wx.getSourceName()).append("#") - .append(wx.getLineNumber()).append(")"); - msg = b.toString(); - // replace wrapper with original exception - if (wrapped instanceof Exception) { - x = (Exception) wrapped; - } - } else if (x instanceof EcmaError) { - msg = x.toString(); - } else { - msg = x.getMessage(); } - + // create and throw a ScriptingException with the right message + String msg = x.getMessage(); throw new ScriptingException(msg, x); } }