public static Exception ThrowAsScriptRuntimeEx(Exception e)
{
while ((e is TargetInvocationException))
{
e = ((TargetInvocationException)e).InnerException;
}
// special handling of Error so scripts would not catch them
if (e is Exception)
{
Rhino.Context cx = GetContext();
if (cx == null || !cx.HasFeature(Rhino.Context.FEATURE_ENHANCED_JAVA_ACCESS))
{
throw (Exception)e;
}
}
if (e is RhinoException)
{
throw (RhinoException)e;
}
throw new WrappedException(e);
}