本文整理汇总了Java中jdk.nashorn.api.scripting.NashornException.getScriptFrames方法的典型用法代码示例。如果您正苦于以下问题:Java NashornException.getScriptFrames方法的具体用法?Java NashornException.getScriptFrames怎么用?Java NashornException.getScriptFrames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.api.scripting.NashornException
的用法示例。
在下文中一共展示了NashornException.getScriptFrames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStackTrace
import jdk.nashorn.api.scripting.NashornException; //导入方法依赖的package包/类
/**
* Nashorn extension: Error.prototype.getStackTrace()
* "stack" property is an array typed value containing {@link StackTraceElement}
* objects of JavaScript stack frames.
*
* @param self self reference
*
* @return stack trace as a script array.
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object getStackTrace(final Object self) {
final ScriptObject sobj = Global.checkObject(self);
final Object exception = ECMAException.getException(sobj);
Object[] res;
if (exception instanceof Throwable) {
res = NashornException.getScriptFrames((Throwable)exception);
} else {
res = ScriptRuntime.EMPTY_ARRAY;
}
return new NativeArray(res);
}
示例2: getStackTrace
import jdk.nashorn.api.scripting.NashornException; //导入方法依赖的package包/类
/**
* Nashorn extension: Error.prototype.getStackTrace()
* "stack" property is an array typed value containing {@link StackTraceElement}
* objects of JavaScript stack frames.
*
* @param self self reference
*
* @return stack trace as a script array.
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object getStackTrace(final Object self) {
Global.checkObject(self);
final ScriptObject sobj = (ScriptObject)self;
final Object exception = ECMAException.getException(sobj);
Object[] res;
if (exception instanceof Throwable) {
res = NashornException.getScriptFrames((Throwable)exception);
} else {
res = ScriptRuntime.EMPTY_ARRAY;
}
return new NativeArray(res);
}
示例3: findScriptTraceElement
import jdk.nashorn.api.scripting.NashornException; //导入方法依赖的package包/类
private static StackTraceElement findScriptTraceElement( final RuntimeException e )
{
final StackTraceElement[] elements = NashornException.getScriptFrames( e );
return elements.length > 0 ? elements[0] : null;
}