本文整理了Java中org.mozilla.javascript.Context.setErrorReporter()
方法的一些代码示例,展示了Context.setErrorReporter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.setErrorReporter()
方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:setErrorReporter
[英]Change the current error reporter.
[中]更改当前错误报告程序。
代码示例来源:origin: alexo/wro4j
/**
* Initialize the context.
*/
private ScriptableObject createContext(final ScriptableObject initialScope) {
final Context context = getContext();
context.setOptimizationLevel(-1);
// TODO redirect errors from System.err to LOG.error()
context.setErrorReporter(new ToolErrorReporter(false));
context.setLanguageVersion(Context.VERSION_1_8);
InputStream script = null;
final ScriptableObject scriptCommon = (ScriptableObject) context.initStandardObjects(initialScope);
try {
script = getClass().getResourceAsStream("commons.js");
context.evaluateReader(scriptCommon, new InputStreamReader(script), "commons.js", 1, null);
} catch (final IOException e) {
throw new RuntimeException("Problem while evaluationg commons script.", e);
} finally {
IOUtils.closeQuietly(script);
}
return scriptCommon;
}
代码示例来源:origin: com.github.tntim96/rhino
@Override
protected void onContextCreated(Context cx)
{
cx.setLanguageVersion(languageVersion);
cx.setOptimizationLevel(optimizationLevel);
if (errorReporter != null) {
cx.setErrorReporter(errorReporter);
}
cx.setGeneratingDebug(generatingDebug);
super.onContextCreated(cx);
}
代码示例来源:origin: org.hibnet/webpipes-rhino
protected Context enterContext() {
Context context = Context.enter();
context.setOptimizationLevel(-1);
// TODO redirect errors from System.err to LOG.error()
context.setErrorReporter(new ToolErrorReporter(false));
context.setLanguageVersion(Context.VERSION_1_8);
return context;
}
代码示例来源:origin: ro.isdc.wro4j/rhino
@Override
protected void onContextCreated(Context cx)
{
cx.setLanguageVersion(languageVersion);
cx.setOptimizationLevel(optimizationLevel);
if (errorReporter != null) {
cx.setErrorReporter(errorReporter);
}
cx.setGeneratingDebug(generatingDebug);
super.onContextCreated(cx);
}
代码示例来源:origin: ro.isdc.wro4j/wro4j-extensions
/**
* Initialize the context.
*/
private ScriptableObject createContext(final ScriptableObject initialScope) {
final Context context = getContext();
context.setOptimizationLevel(-1);
// TODO redirect errors from System.err to LOG.error()
context.setErrorReporter(new ToolErrorReporter(false));
context.setLanguageVersion(Context.VERSION_1_8);
InputStream script = null;
final ScriptableObject scriptCommon = (ScriptableObject) context.initStandardObjects(initialScope);
try {
script = new AutoCloseInputStream(getClass().getResourceAsStream("commons.js"));
context.evaluateReader(scriptCommon, new InputStreamReader(script), "commons.js", 1, null);
} catch (final IOException e) {
throw new RuntimeException("Problem while evaluationg commons script.", e);
} finally {
IOUtils.closeQuietly(script);
}
return scriptCommon;
}
代码示例来源:origin: ro.isdc.wro4j/rhino
String resultString = "";
ErrorReporter savedErrorReporter = cx.getErrorReporter();
cx.setErrorReporter(new ToolErrorReporter(false, this.getErr()));
try {
testCount++;
this.setOut(savedOut);
this.setErr(savedErr);
cx.setErrorReporter(savedErrorReporter);
resultString += err.toString() + out.toString();
代码示例来源:origin: com.github.tntim96/rhino
String resultString = "";
ErrorReporter savedErrorReporter = cx.getErrorReporter();
cx.setErrorReporter(new ToolErrorReporter(false, this.getErr()));
try {
testCount++;
this.setOut(savedOut);
this.setErr(savedErr);
cx.setErrorReporter(savedErrorReporter);
resultString += err.toString() + out.toString();
代码示例来源:origin: org.eclipse.dirigible/dirigible-engine-javascript-rhino
private void enableDebugger(HttpServletRequest request, HttpServletResponse response, String moduleOrCode, Context context) {
Context rhinoContext = (Context) context;
ErrorReporter reporter = new RhinoJavascriptDebugInvocationErrorReporter();
rhinoContext.setErrorReporter(reporter);
String userId = UserFacade.getName(request);
logger.debug("creating DebugModel ...");
DebugModel debugModel = DebugManager.getDebugModel(userId);
if (debugModel == null) {
debugModel = DebugModelFacade.createDebugModel(userId, new RhinoJavascriptDebugController(userId));
}
logger.debug("creating JavascriptDebugger ...");
RhinoJavascriptDebugger debugger = new RhinoJavascriptDebugger(debugModel, request);
rhinoContext.setDebugger(debugger, JAVA_SCRIPT_DEBUGGER);
logger.debug("created JavascriptDebugger");
RhinoJavascriptDebugSender.sendCurrentSessions(userId, debugModel);
rhinoContext.setGeneratingDebug(true);
rhinoContext.setOptimizationLevel(-1);
}
代码示例来源:origin: javanna/elasticshell
@Override
protected void init() {
super.init();
Context context = Context.enter();
context.setErrorReporter(new RhinoErrorReporter(false, console.out()));
context.setWrapFactory(new RhinoCustomWrapFactory());
}
代码示例来源:origin: org.zkoss.maven/yuicompressor-maven-plugin-zk
cx.setErrorReporter(reporter);
try {
代码示例来源:origin: org.apache.cocoon/cocoon-flowscript-impl
context.setGeneratingDebug(true);
context.setCompileFunctionsWithDynamicScope(true);
context.setErrorReporter(new JSErrorReporter());
内容来源于网络,如有侵权,请联系作者删除!