if (error instanceof Throwable) {
throwable = (Throwable) error;
}
else if (error instanceof Scriptable) {
Scriptable nativeError = (Scriptable) error;
if (nativeError.has("rhinoException", nativeError)) {
throwable = (RhinoException) ((NativeJavaObject) nativeError.get("rhinoException", nativeError)).unwrap();
}
else if (nativeError.has("javaException", nativeError)) {
throwable = (Throwable) ((NativeJavaObject) nativeError.get("javaException", nativeError)).unwrap();
}
else if (nativeError.has("message", nativeError)) {
additionalMsg = (String) nativeError.get("message", nativeError);
}
else {
additionalMsg = "(scriptable error object without further information: " + nativeError.getClass().getName() + ")";
}
if (nativeError.has("lineNumber", nativeError) && !(throwable instanceof RhinoException)) {
additionalMsg += ". Line number: " + (Integer) nativeError.get("lineNumber", nativeError);
}
}
else {
additionalMsg = "(error object of invalid type: " + error.getClass().getName() + ")";
}