public Mark getProblemMark() { return Mark.from(_source.getProblemMark()); } }
public String getProblem() { return _source.getProblem(); }
public String getContext() { return _source.getContext(); }
public ParsingError(ErrorCode errorCode, MarkedYAMLException cause) { this(ParsingErrorLevel.ERROR, errorCode, cause.getContext(), cause.getContextMark() != null ? cause.getContextMark() : cause.getProblemMark(), cause.getProblem(), cause.getProblemMark(), null); } }
private static String formatYamlExceptionMessage(Resource res, YAMLException ye) { final StringBuilder sb = new StringBuilder(); sb.append("YAML parsing error in ").append(res); if (ye instanceof MarkedYAMLException) { final Mark mark = ((MarkedYAMLException) ye).getProblemMark(); final String snippet = mark != null ? mark.get_snippet() : null; final String problem = ((MarkedYAMLException) ye).getProblem(); if (mark != null) { sb.append(" at line ").append(mark.getLine()).append(", column ").append(mark.getColumn()); } if (snippet != null) { sb.append(":\n"); sb.append(snippet); } if (problem != null) { // TODO SnakeYaml tends to be a bit nasty about this "problem", e.g org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens() prints the actual char THEN it's representation, so you end up with a big fat actual tab in the message instead of JUST \t(TAB) // See https://code.google.com/p/snakeyaml/issues/detail?id=209 sb.append(": ").append(problem.replaceAll("\\s*\\t\\s*", " ")); } } else { sb.append(": ").append(ye.getMessage()); } return sb.toString(); } }
private static void raiseParserException(ThreadContext context, IRubyObject yaml, MarkedYAMLException mye, IRubyObject rbPath) { Ruby runtime; Mark mark; RubyClass se; IRubyObject exception; runtime = context.runtime; se = (RubyClass)runtime.getModule("Psych").getConstant("SyntaxError"); mark = mye.getProblemMark(); exception = se.newInstance(context, new IRubyObject[] { rbPath, runtime.newFixnum(mark.getLine() + 1), runtime.newFixnum(mark.getColumn() + 1), runtime.newFixnum(mark.getIndex()), (null == mye.getProblem() ? runtime.getNil() : runtime.newString(mye.getProblem())), (null == mye.getContext() ? runtime.getNil() : runtime.newString(mye.getContext())) }, Block.NULL_BLOCK); RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[] { exception }, Block.NULL_BLOCK); }
public YamlSyntaxErrorException(String message, MarkedYAMLException cause) { super(cause.getContext(), cause.getContextMark(), message, cause.getProblemMark()); }
public MarkedYAMLException apply(MarkedYAMLException e, String yaml) throws IOException { Mark problemMark = e.getProblemMark(); Optional<YamlLine> prevLine = getLine(yaml, problemMark.getLine() - 1); Optional<YamlLine> line = getLine(problemMark.get_snippet(0, 100), 0); if (prevLine.isPresent() && line.isPresent()) { YamlLine prev = prevLine.get(); YamlLine current = line.get(); if (isIncorrectIndentation(prev, current)) { return incorrectIndentationException(prev, current, e); } else if (isItemOutsideSequence(prev, current)) { return itemOutsideSequence(e); } } return new YamlSyntaxErrorException(e.getMessage(), e); }
public Mark getContextMark() { return Mark.from(_source.getContextMark()); }
@Override public String getMessage() { return toString(); }
errorMessage.add(createErrorResult(mye.getProblem(), mye.getProblemMark(), mye.getProblemMark()));
private static void raiseParserException(ThreadContext context, IRubyObject yaml, MarkedYAMLException mye, IRubyObject rbPath) { Ruby runtime; Mark mark; RubyClass se; IRubyObject exception; runtime = context.runtime; se = (RubyClass)runtime.getModule("Psych").getConstant("SyntaxError"); mark = mye.getProblemMark(); exception = se.newInstance(context, new IRubyObject[] { rbPath, runtime.newFixnum(mark.getLine() + 1), runtime.newFixnum(mark.getColumn() + 1), runtime.newFixnum(mark.getIndex()), (null == mye.getProblem() ? runtime.getNil() : runtime.newString(mye.getProblem())), (null == mye.getContext() ? runtime.getNil() : runtime.newString(mye.getContext())) }, Block.NULL_BLOCK); RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[] { exception }, Block.NULL_BLOCK); }
private static Node buildYamlErrorNode(MarkedYAMLException e, String resourcePath) { final ErrorNode errorNode = new ErrorNode("Underlying error while parsing YAML syntax: '" + e.getMessage() + "'"); final Mark problemMark = e.getProblemMark(); errorNode.setStartPosition(new DefaultPosition(problemMark.getIndex(), problemMark.getLine(), 0, resourcePath, new DefaultResourceLoader())); errorNode.setEndPosition(new DefaultPosition(problemMark.getIndex() + 1, problemMark.getLine(), problemMark.getColumn(), resourcePath, new DefaultResourceLoader())); return errorNode; }
public Mark getContextMark() { return Mark.from(_source.getContextMark()); }
@Override public String getMessage() { return toString(); }
public Mark getProblemMark() { return Mark.from(_source.getProblemMark()); } }
errorMessage.add(createErrorResult(mye.getProblem(), mye.getProblemMark(), mye.getProblemMark()));
public String getProblem() { return _source.getProblem(); }
public String getContext() { return _source.getContext(); }
public Mark getContextMark() { return Mark.from(_source.getContextMark()); }