* Simplify exception handling in invoke(), bugs in Rhino have been fixed.
This commit is contained in:
parent
54ab7ca121
commit
572194d2bc
1 changed files with 6 additions and 26 deletions
|
@ -335,38 +335,18 @@ public class RhinoEngine implements ScriptingEngine {
|
||||||
throw new TimeoutException();
|
throw new TimeoutException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create and throw a ScriptingException with the right message
|
if (x instanceof WrappedException) {
|
||||||
String msg;
|
|
||||||
if (x instanceof JavaScriptException) {
|
|
||||||
// created by javascript throw statement
|
|
||||||
msg = x.getMessage();
|
|
||||||
} else if (x instanceof WrappedException) {
|
|
||||||
// wrapped java excepiton
|
// wrapped java excepiton
|
||||||
WrappedException wx = (WrappedException) x;
|
Throwable wrapped = ((WrappedException) x).getWrappedException();
|
||||||
Throwable wrapped = wx.getWrappedException();
|
// rethrow if this is a wrapped concurrency or redirect exception
|
||||||
// if this is a wrapped concurrencyException, rethrow it.
|
|
||||||
if (wrapped instanceof ConcurrencyException) {
|
if (wrapped instanceof ConcurrencyException) {
|
||||||
throw (ConcurrencyException) wrapped;
|
throw (ConcurrencyException) wrapped;
|
||||||
}
|
} else if (wrapped instanceof RedirectException) {
|
||||||
// also check if this is a wrapped redirect exception
|
|
||||||
if (wrapped instanceof RedirectException) {
|
|
||||||
throw (RedirectException) wrapped;
|
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);
|
throw new ScriptingException(msg, x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue