public String extract (ParserRuntimeException exception) { String[] split = exception.getMessage().split("\n"); return split[1] + "\n" + split[2]; } }
public String extract (ParserRuntimeException exception) { String[] split = exception.getMessage().split("\n"); return split[1] + "\n" + split[2]; } }
return 0; }, e.getMessage()); printError(doc.position(), e.getMessage());
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 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; } }