public String extract (ParserRuntimeException exception) { String[] split = exception.getMessage().split("\n"); return split[1] + "\n" + split[2]; } }
private char throwParsingException() { throw new ParserRuntimeException("Parser read more than 100K chars beyond EOI, " + "verify that your grammar does not consume EOI indefinitely!"); }
public Template parse(final String input) throws IOException { try { ParseRunner<BaseTemplate> runner = new SafeReportingParseRunner(template()); ParsingResult<BaseTemplate> result = runner.run(input); if (result.hasErrors()) { ParseError error = result.parseErrors.get(0); String msg = ErrorFormatter.printParseError(filename, error, noffset, stacktraceList); throw new HandlebarsException(msg); } TemplateList sequence = (TemplateList) result.resultValue; removeBlanks(sequence); if (sequence.size() == 1) { return sequence.iterator().next(); } return sequence; } catch (ParserRuntimeException ex) { Throwable cause = ex.getCause(); if (cause instanceof HandlebarsException) { throw (HandlebarsException) cause; } HandlebarsException hex = new HandlebarsException(ex.getMessage()); hex.initCause(ex.getCause() == null ? ex : ex.getCause()); throw hex; } }
public static JtwigDocument parse (JtwigResource input) throws ParseException { try { ReportingParseRunner<Object> runner = new ReportingParseRunner<Object>(createParser(JtwigParser.class).start()); ParsingResult<Object> result = runner.run(FileUtils.readAllText(input.retrieve(), Charset.defaultCharset())); return (JtwigDocument) result.resultValue; } catch (ParserRuntimeException e) { if (e.getCause() instanceof ParseBypassException) { ParseException innerException = ((ParseBypassException) e.getCause()).getInnerException(); innerException.setExpression(e.getMessage()); throw innerException; } else throw new ParseException(e); } catch (ResourceException e) { throw new ParseException(e); } }
public static JtwigDocument parse (JtwigResource input) throws ParseException { try { ReportingParseRunner<Object> runner = new ReportingParseRunner<Object>(createParser(JtwigParser.class).start()); ParsingResult<Object> result = runner.run(FileUtils.readAllText(input.retrieve(), Charset.defaultCharset())); return (JtwigDocument) result.resultValue; } catch (ParserRuntimeException e) { if (e.getCause() instanceof ParseBypassException) { ParseException innerException = ((ParseBypassException) e.getCause()).getInnerException(); innerException.setExpression(e.getMessage()); throw innerException; } else throw new ParseException(e); } catch (ResourceException e) { throw new ParseException(e); } }
public String extract (ParserRuntimeException exception) { String[] split = exception.getMessage().split("\n"); return split[1] + "\n" + split[2]; } }
public boolean runMatcher() { try { if (matchHandler.match(this)) { if (parent != null) { parent.currentIndex = currentIndex; parent.currentChar = currentChar; } matcher = null; // "retire" this context return true; } matcher = null; // "retire" this context until is "activated" again by a getSubContext(...) on the parent return false; } catch (ParserRuntimeException e) { throw e; // don't wrap, just bubble up } catch (RecoveringParseRunner.TimeoutException e) { throw e; // don't wrap, just bubble up } catch (Throwable e) { throw new ParserRuntimeException(e, printParseError(new BasicParseError(inputBuffer, currentIndex, StringUtils.escape(String.format("Error while parsing %s '%s' at input position", matcher instanceof ActionMatcher ? "action" : "rule", getPath())))) + '\n' + e); } } }
return 0; }, e.getMessage()); printError(doc.position(), e.getMessage());
@Override public boolean run(Context ctx) { String expression = match(); expression = expandEnvironmentVariables(expression); try { Filter f = ECQL.toFilter(expression); ctx.getValueStack().push(new Data(f)); return true; } catch (CQLException e) { throw new ParserRuntimeException( reportPosition(ctx) + ". " + e.getMessage(), e); } } });
@Override public boolean run(Context ctx) { String expression = match(); expression = expandEnvironmentVariables(expression); try { org.opengis.filter.expression.Expression e = ECQL.toExpression(expression); ctx.getValueStack().push(new Value.Expression(e)); return true; } catch (CQLException e) { throw new ParserRuntimeException( reportPosition(ctx) + ". " + e.getMessage(), e); } } });