src/jdk/nashorn/internal/objects/NativeError.java
Print this page
@@ -127,11 +127,11 @@
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object captureStackTrace(final Object self, final Object errorObj) {
Global.checkObject(errorObj);
final ScriptObject sobj = (ScriptObject)errorObj;
final ECMAException exp = new ECMAException(sobj, null);
- sobj.set("stack", NashornException.getScriptStackString(exp), false);
+ sobj.set("stack", getScriptStackString(sobj, exp), false);
return UNDEFINED;
}
/**
* Nashorn extension: Error.dumpStack
@@ -286,11 +286,11 @@
return sobj.get(STACK);
}
final Object exception = ECMAException.getException(sobj);
if (exception instanceof Throwable) {
- return NashornException.getScriptStackString((Throwable)exception);
+ return getScriptStackString(sobj, (Throwable)exception);
} else {
return "";
}
}
@@ -360,6 +360,10 @@
return MethodHandles.lookup().findStatic(NativeError.class, name, MH.type(rtype, types));
} catch (final NoSuchMethodException | IllegalAccessException e) {
throw new MethodHandleFactory.LookupException(e);
}
}
+
+ private static String getScriptStackString(final ScriptObject sobj, final Throwable exp) {
+ return JSType.toString(sobj) + "\n" + NashornException.getScriptStackString(exp);
+ }
}