本文整理汇总了Java中jdk.nashorn.internal.runtime.ErrorManager.format方法的典型用法代码示例。如果您正苦于以下问题:Java ErrorManager.format方法的具体用法?Java ErrorManager.format怎么用?Java ErrorManager.format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.runtime.ErrorManager
的用法示例。
在下文中一共展示了ErrorManager.format方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: error
import jdk.nashorn.internal.runtime.ErrorManager; //导入方法依赖的package包/类
/**
* Report an error.
*
* @param errorType The error type
* @param message Error message.
* @return ParserException upon failure. Caller should throw and not ignore
*/
protected final ParserException error(final JSErrorType errorType, final String message) {
// TODO - column needs to account for tabs.
final int position = Token.descPosition(token);
final int column = position - linePosition;
final String formatted = ErrorManager.format(message, source, line, column, token);
return new ParserException(errorType, formatted, source, line, column, token);
}
示例2: throwParserException
import jdk.nashorn.internal.runtime.ErrorManager; //导入方法依赖的package包/类
private void throwParserException(final String message, final Node origin) {
if (origin == null) {
throw new ParserException(message);
}
final Source source = compiler.getSource();
final long token = origin.getToken();
final int line = source.getLine(origin.getStart());
final int column = source.getColumn(origin.getStart());
final String formatted = ErrorManager.format(message, source, line, column, token);
throw new ParserException(JSErrorType.SYNTAX_ERROR, formatted, source, line, column, token);
}
示例3: error
import jdk.nashorn.internal.runtime.ErrorManager; //导入方法依赖的package包/类
ParserException error(final String message, final int start, final int length) throws ParserException {
final long token = Token.toDesc(STRING, start, length);
final int pos = Token.descPosition(token);
final Source src = Source.sourceFor("<json>", source);
final int lineNum = src.getLine(pos);
final int columnNum = src.getColumn(pos);
final String formatted = ErrorManager.format(message, src, lineNum, columnNum, token);
return new ParserException(JSErrorType.SYNTAX_ERROR, formatted, src, lineNum, columnNum, token);
}
示例4: throwNotImplementedYet
import jdk.nashorn.internal.runtime.ErrorManager; //导入方法依赖的package包/类
private void throwNotImplementedYet(final String msgId, final Node node) {
final long token = node.getToken();
final int line = source.getLine(node.getStart());
final int column = source.getColumn(node.getStart());
final String message = ECMAErrors.getMessage("unimplemented." + msgId);
final String formatted = ErrorManager.format(message, source, line, column, token);
throw new RuntimeException(formatted);
}
示例5: error
import jdk.nashorn.internal.runtime.ErrorManager; //导入方法依赖的package包/类
/**
* Generate a runtime exception
*
* @param message error message
* @param type token type
* @param start start position of lexed error
* @param length length of lexed error
* @throws ParserException unconditionally
*/
protected void error(final String message, final TokenType type, final int start, final int length) throws ParserException {
final long token = Token.toDesc(type, start, length);
final int pos = Token.descPosition(token);
final int lineNum = source.getLine(pos);
final int columnNum = source.getColumn(pos);
final String formatted = ErrorManager.format(message, source, lineNum, columnNum, token);
throw new ParserException(JSErrorType.SYNTAX_ERROR, formatted, source, lineNum, columnNum, token);
}