本文整理了Java中org.mozilla.javascript.Context.reportError()
方法的一些代码示例,展示了Context.reportError()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.reportError()
方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:reportError
[英]Report an error using the error reporter for the current thread.
[中]使用当前线程的错误报告器报告错误。
代码示例来源:origin: pentaho/pentaho-kettle
actualContext.evaluateReader( eval_scope, inStream, fileName, 1, null );
} catch ( FileNotFoundException Signal ) {
Context.reportError( "Unable to open file \"" + fileName + "\" (reason: \"" + Signal.getMessage() + "\")" );
} catch ( WrappedException Signal ) {
Context.reportError( "WrappedException while evaluating file \""
+ fileName + "\" (reason: \"" + Signal.getMessage() + "\")" );
} catch ( EvaluatorException Signal ) {
Context.reportError( "EvaluatorException while evaluating file \""
+ fileName + "\" (reason: \"" + Signal.getMessage() + "\")" );
} catch ( JavaScriptException Signal ) {
Context.reportError( "JavaScriptException while evaluating file \""
+ fileName + "\" (reason: \"" + Signal.getMessage() + "\")" );
} catch ( IOException Signal ) {
Context.reportError( "Error while reading file \""
+ fileName + "\" (reason: \"" + Signal.getMessage() + "\")" );
} catch ( KettleFileException Signal ) {
Context.reportError( "Error while reading file \""
+ fileName + "\" (reason: \"" + Signal.getMessage() + "\")" );
} finally {
代码示例来源:origin: com.github.tntim96/rhino
/**
* Report an error using the error reporter for the current thread.
*
* @param message the error message to report
* @see org.mozilla.javascript.ErrorReporter
*/
public static void reportError(String message)
{
int[] linep = { 0 };
String filename = getSourcePositionFromStack(linep);
Context.reportError(message, filename, linep[0], null, 0);
}
代码示例来源:origin: rhino/js
/**
* Report an error using the error reporter for the current thread.
*
* @param message the error message to report
* @see org.mozilla.javascript.ErrorReporter
*/
public static void reportError(String message)
{
int[] linep = { 0 };
String filename = getSourcePositionFromStack(linep);
Context.reportError(message, filename, linep[0], null, 0);
}
代码示例来源:origin: io.apigee/rhino
/**
* Report an error using the error reporter for the current thread.
*
* @param message the error message to report
* @see org.mozilla.javascript.ErrorReporter
*/
public static void reportError(String message)
{
int[] linep = { 0 };
String filename = getSourcePositionFromStack(linep);
Context.reportError(message, filename, linep[0], null, 0);
}
代码示例来源:origin: com.sun.phobos/phobos-rhino
/**
* Report an error using the error reporter for the current thread.
*
* @param message the error message to report
* @see org.mozilla.javascript.ErrorReporter
*/
public static void reportError(String message)
{
int[] linep = { 0 };
String filename = getSourcePositionFromStack(linep);
Context.reportError(message, filename, linep[0], null, 0);
}
代码示例来源:origin: org.wso2.bpel.extensions/ode-bpel-extensions-e4x
/**
* This method is exposed to the JS environment and allows converting from
* JavaScript E4X objects to W3C DOM nodes.
*/
public static Node js2dom(Context cx, Scriptable thisObj, Object[] args,
Function funObj) {
if (args.length != 1) {
Context.reportError("js2dom expects one E4X XML parameter");
}
return XMLLibImpl.toDomNode(args[0]);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
/**
* Report an error using the error reporter for the current thread.
*
* @param message the error message to report
* @see org.mozilla.javascript.ErrorReporter
*/
public static void reportError(String message)
{
int[] linep = { 0 };
String filename = getSourcePositionFromStack(linep);
Context.reportError(message, filename, linep[0], null, 0);
}
代码示例来源:origin: geogebra/geogebra
/**
* Report an error using the error reporter for the current thread.
*
* @param message the error message to report
* @see org.mozilla.javascript.ErrorReporter
*/
public static void reportError(String message)
{
int[] linep = { 0 };
String filename = getSourcePositionFromStack(linep);
Context.reportError(message, filename, linep[0], null, 0);
}
代码示例来源:origin: org.dojotoolkit/dojo-shrinksafe
public Object run(Context cx) {
if (type == PROCESS_FILES) {
try {
processFiles(cx, args);
} catch (IOException ioe) {
Context.reportError(ioe.toString());
}
} else {
throw Kit.codeBug();
}
return null;
}
代码示例来源:origin: org.wso2.bpel.extensions/ode-bpel-extensions-e4x
/**
* This method is exposed to the JS environment and allows users to
* throw BPEL faults.
*
* @throws FaultException
*/
public static void throwFault(Context cx, Scriptable thisObj, Object[] args,
Function funObj) throws FaultException {
if (args.length != 3) {
Context.reportError("throwFault expects the following parameters: throwFault(namespace, localname, faultMessage)");
}
String ns = Context.toString(args[0]);
String localname = Context.toString(args[1]);
String msg = Context.toString(args[2]);
throw new FaultException(new QName(ns, localname), msg);
}
代码示例来源:origin: com.github.tntim96/rhino
public static void processFileNoThrow(Context cx, Scriptable scope, String filename) {
try {
processFile(cx, scope, filename);
} catch (IOException ioex) {
Context.reportError(ToolErrorReporter.getMessage(
"msg.couldnt.read.source", filename, ioex.getMessage()));
exitCode = EXITCODE_FILE_NOT_FOUND;
} catch (RhinoException rex) {
ToolErrorReporter.reportException(
cx.getErrorReporter(), rex);
exitCode = EXITCODE_RUNTIME_ERROR;
} catch (VirtualMachineError ex) {
// Treat StackOverflow and OutOfMemory as runtime errors
ex.printStackTrace();
String msg = ToolErrorReporter.getMessage(
"msg.uncaughtJSException", ex.toString());
Context.reportError(msg);
exitCode = EXITCODE_RUNTIME_ERROR;
}
}
代码示例来源:origin: ro.isdc.wro4j/rhino
public static void processFileNoThrow(Context cx, Scriptable scope, String filename) {
try {
processFile(cx, scope, filename);
} catch (IOException ioex) {
Context.reportError(ToolErrorReporter.getMessage(
"msg.couldnt.read.source", filename, ioex.getMessage()));
exitCode = EXITCODE_FILE_NOT_FOUND;
} catch (RhinoException rex) {
ToolErrorReporter.reportException(
cx.getErrorReporter(), rex);
exitCode = EXITCODE_RUNTIME_ERROR;
} catch (VirtualMachineError ex) {
// Treat StackOverflow and OutOfMemory as runtime errors
ex.printStackTrace();
String msg = ToolErrorReporter.getMessage(
"msg.uncaughtJSException", ex.toString());
Context.reportError(msg);
exitCode = EXITCODE_RUNTIME_ERROR;
}
}
代码示例来源:origin: geogebra/geogebra
/**
* Report a warning using the error reporter for the current thread.
*
* @param message the warning message to report
* @param sourceName a string describing the source, such as a filename
* @param lineno the starting line number
* @param lineSource the text of the line (may be null)
* @param lineOffset the offset into lineSource where problem was detected
* @see org.mozilla.javascript.ErrorReporter
*/
public static void reportWarning(String message, String sourceName,
int lineno, String lineSource,
int lineOffset)
{
Context cx = Context.getContext();
if (cx.hasFeature(FEATURE_WARNING_AS_ERROR))
reportError(message, sourceName, lineno, lineSource, lineOffset);
else
cx.getErrorReporter().warning(message, sourceName, lineno,
lineSource, lineOffset);
}
代码示例来源:origin: com.sun.phobos/phobos-rhino
/**
* Report a warning using the error reporter for the current thread.
*
* @param message the warning message to report
* @param sourceName a string describing the source, such as a filename
* @param lineno the starting line number
* @param lineSource the text of the line (may be null)
* @param lineOffset the offset into lineSource where problem was detected
* @see org.mozilla.javascript.ErrorReporter
*/
public static void reportWarning(String message, String sourceName,
int lineno, String lineSource,
int lineOffset)
{
Context cx = Context.getContext();
if (cx.hasFeature(FEATURE_WARNING_AS_ERROR))
reportError(message, sourceName, lineno, lineSource, lineOffset);
else
cx.getErrorReporter().warning(message, sourceName, lineno,
lineSource, lineOffset);
}
代码示例来源:origin: rhino/js
/**
* Report a warning using the error reporter for the current thread.
*
* @param message the warning message to report
* @param sourceName a string describing the source, such as a filename
* @param lineno the starting line number
* @param lineSource the text of the line (may be null)
* @param lineOffset the offset into lineSource where problem was detected
* @see org.mozilla.javascript.ErrorReporter
*/
public static void reportWarning(String message, String sourceName,
int lineno, String lineSource,
int lineOffset)
{
Context cx = Context.getContext();
if (cx.hasFeature(FEATURE_WARNING_AS_ERROR))
reportError(message, sourceName, lineno, lineSource, lineOffset);
else
cx.getErrorReporter().warning(message, sourceName, lineno,
lineSource, lineOffset);
}
代码示例来源:origin: com.github.tntim96/rhino
/**
* Report a warning using the error reporter for the current thread.
*
* @param message the warning message to report
* @param sourceName a string describing the source, such as a filename
* @param lineno the starting line number
* @param lineSource the text of the line (may be null)
* @param lineOffset the offset into lineSource where problem was detected
* @see org.mozilla.javascript.ErrorReporter
*/
public static void reportWarning(String message, String sourceName,
int lineno, String lineSource,
int lineOffset)
{
Context cx = Context.getContext();
if (cx.hasFeature(FEATURE_WARNING_AS_ERROR))
reportError(message, sourceName, lineno, lineSource, lineOffset);
else
cx.getErrorReporter().warning(message, sourceName, lineno,
lineSource, lineOffset);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
/**
* Report a warning using the error reporter for the current thread.
*
* @param message the warning message to report
* @param sourceName a string describing the source, such as a filename
* @param lineno the starting line number
* @param lineSource the text of the line (may be null)
* @param lineOffset the offset into lineSource where problem was detected
* @see org.mozilla.javascript.ErrorReporter
*/
public static void reportWarning(String message, String sourceName,
int lineno, String lineSource,
int lineOffset)
{
Context cx = Context.getContext();
if (cx.hasFeature(FEATURE_WARNING_AS_ERROR))
reportError(message, sourceName, lineno, lineSource, lineOffset);
else
cx.getErrorReporter().warning(message, sourceName, lineno,
lineSource, lineOffset);
}
代码示例来源:origin: io.apigee/rhino
/**
* Report a warning using the error reporter for the current thread.
*
* @param message the warning message to report
* @param sourceName a string describing the source, such as a filename
* @param lineno the starting line number
* @param lineSource the text of the line (may be null)
* @param lineOffset the offset into lineSource where problem was detected
* @see org.mozilla.javascript.ErrorReporter
*/
public static void reportWarning(String message, String sourceName,
int lineno, String lineSource,
int lineOffset)
{
Context cx = Context.getContext();
if (cx.hasFeature(FEATURE_WARNING_AS_ERROR))
reportError(message, sourceName, lineno, lineSource, lineOffset);
else
cx.getErrorReporter().warning(message, sourceName, lineno,
lineSource, lineOffset);
}
代码示例来源:origin: com.github.tntim96/rhino
static void evalInlineScript(Context cx, String scriptText) {
try {
Script script = cx.compileString(scriptText, "<command>", 1, null);
if (script != null) {
script.exec(cx, getShellScope());
}
} catch (RhinoException rex) {
ToolErrorReporter.reportException(
cx.getErrorReporter(), rex);
exitCode = EXITCODE_RUNTIME_ERROR;
} catch (VirtualMachineError ex) {
// Treat StackOverflow and OutOfMemory as runtime errors
ex.printStackTrace();
String msg = ToolErrorReporter.getMessage(
"msg.uncaughtJSException", ex.toString());
Context.reportError(msg);
exitCode = EXITCODE_RUNTIME_ERROR;
}
}
代码示例来源:origin: ro.isdc.wro4j/rhino
static void evalInlineScript(Context cx, String scriptText) {
try {
Script script = cx.compileString(scriptText, "<command>", 1, null);
if (script != null) {
script.exec(cx, getShellScope());
}
} catch (RhinoException rex) {
ToolErrorReporter.reportException(
cx.getErrorReporter(), rex);
exitCode = EXITCODE_RUNTIME_ERROR;
} catch (VirtualMachineError ex) {
// Treat StackOverflow and OutOfMemory as runtime errors
ex.printStackTrace();
String msg = ToolErrorReporter.getMessage(
"msg.uncaughtJSException", ex.toString());
Context.reportError(msg);
exitCode = EXITCODE_RUNTIME_ERROR;
}
}
内容来源于网络,如有侵权,请联系作者删除!