src/jdk/nashorn/internal/objects/NativeError.java
Print this page
*** 127,137 ****
@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);
return UNDEFINED;
}
/**
* Nashorn extension: Error.dumpStack
--- 127,137 ----
@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", getScriptStackString(sobj, exp), false);
return UNDEFINED;
}
/**
* Nashorn extension: Error.dumpStack
*** 286,296 ****
return sobj.get(STACK);
}
final Object exception = ECMAException.getException(sobj);
if (exception instanceof Throwable) {
! return NashornException.getScriptStackString((Throwable)exception);
} else {
return "";
}
}
--- 286,296 ----
return sobj.get(STACK);
}
final Object exception = ECMAException.getException(sobj);
if (exception instanceof Throwable) {
! return getScriptStackString(sobj, (Throwable)exception);
} else {
return "";
}
}
*** 360,365 ****
--- 360,369 ----
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);
+ }
}