From 6da249a73d84a50684f0235f22c954c1a3ad58e0 Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 26 Nov 2003 11:38:36 +0000 Subject: [PATCH] Rethrow wrapped ConcurrencyExceptions. Also updated code to rethrow wrapped TimeoutExceptions. --- src/helma/scripting/rhino/RhinoEngine.java | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/helma/scripting/rhino/RhinoEngine.java b/src/helma/scripting/rhino/RhinoEngine.java index 4222edbf..05686a21 100644 --- a/src/helma/scripting/rhino/RhinoEngine.java +++ b/src/helma/scripting/rhino/RhinoEngine.java @@ -276,26 +276,25 @@ public class RhinoEngine implements ScriptingEngine { } catch (ConcurrencyException concur) { throw concur; } catch (Exception x) { - // check if this is a redirect exception, which has been converted by fesi - // into an EcmaScript exception, which is why we can't explicitly catch it - if (reval.res.getRedirect() != null) { - throw new RedirectException(reval.res.getRedirect()); - } - - // do the same for not-modified responses - if (reval.res.getNotModified()) { - throw new RedirectException(null); - } - // has the request timed out? If so, throw TimeoutException if (thread != Thread.currentThread()) throw new TimeoutException (); + // create and throw a ScriptingException with the right message String msg; if (x instanceof JavaScriptException) { msg = ((JavaScriptException) x).getValue().toString(); } else if (x instanceof WrappedException) { - msg = ((WrappedException) x).getWrappedException().toString(); + Throwable wrapped = ((WrappedException) x).getWrappedException(); + // if this is a wrapped concurrencyException, rethrow it. + if (wrapped instanceof ConcurrencyException) { + throw (ConcurrencyException) wrapped; + } + // also check if this is a wrapped redirect exception + if (wrapped instanceof RedirectException) { + throw (RedirectException) wrapped; + } + msg = wrapped.toString(); } else { msg = x.toString(); }