/** * @since 2.3.20 */ public ParseException(String description, Template template, Token tk, Throwable cause) { this(description, template == null ? null : template.getSourceName(), tk.beginLine, tk.beginColumn, tk.endLine, tk.endColumn, cause); }
/** * @since 2.3.21 */ public ParseException(String description, Template template, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber, Throwable cause) { this(description, template == null ? null : template.getSourceName(), lineNumber, columnNumber, endLineNumber, endColumnNumber, cause); }
/** * @deprecated Use {@link #ParseException(String, Template, int, int, int, int, Throwable)} instead, as IDE-s need * the end position of the error too. * @since 2.3.20 */ @Deprecated public ParseException(String description, Template template, int lineNumber, int columnNumber, Throwable cause) { this(description, template == null ? null : template.getSourceName(), lineNumber, columnNumber, 0, 0, cause); }
private static String formatLocation(String preposition, Template template, int line, int column) { return formatLocation(preposition, template != null ? template.getSourceName() : null, line, column); }
/** * @since 2.3.20 */ public ParseException(String description, TemplateObject tobj, Throwable cause) { this(description, tobj.getTemplate() == null ? null : tobj.getTemplate().getSourceName(), tobj.beginLine, tobj.beginColumn, tobj.endLine, tobj.endColumn, cause); }
static String formatLocationForEvaluationError(Macro macro, int line, int column) { Template t = macro.getTemplate(); return formatLocation("at", t != null ? t.getSourceName() : null, macro.getName(), macro.isFunction(), line, column); }
private OutputFormat getFormatFromStdFileExt() { String sourceName = template.getSourceName(); if (sourceName == null) { return null; // Not possible anyway... } int ln = sourceName.length(); if (ln < 5) return null; char c = sourceName.charAt(ln - 5); if (c != '.') return null; c = sourceName.charAt(ln - 4); if (c != 'f' && c != 'F') return null; c = sourceName.charAt(ln - 3); if (c != 't' && c != 'T') return null; c = sourceName.charAt(ln - 2); if (c != 'l' && c != 'L') return null; c = sourceName.charAt(ln - 1); try { // Note: We get the output formats by name, so that custom overrides take effect. if (c == 'h' || c == 'H') { return template.getConfiguration().getOutputFormat(HTMLOutputFormat.INSTANCE.getName()); } if (c == 'x' || c == 'X') { return template.getConfiguration().getOutputFormat(XMLOutputFormat.INSTANCE.getName()); } } catch (UnregisteredOutputFormatException e) { throw new BugException("Unregistered std format", e); } return null; }
private void calculatePosition() { synchronized (lock) { if (!positionsCalculated) { // The expressions is the argument of the template element, so we prefer it as it's more specific. TemplateObject templateObject = blamedExpression != null ? (TemplateObject) blamedExpression : ( ftlInstructionStackSnapshot != null && ftlInstructionStackSnapshot.length != 0 ? ftlInstructionStackSnapshot[0] : null); // Line number blow 0 means no info, negative means position in ?eval-ed value that we won't use here. if (templateObject != null && templateObject.getBeginLine() > 0) { final Template template = templateObject.getTemplate(); templateName = template != null ? template.getName() : null; templateSourceName = template != null ? template.getSourceName() : null; lineNumber = Integer.valueOf(templateObject.getBeginLine()); columnNumber = Integer.valueOf(templateObject.getBeginColumn()); endLineNumber = Integer.valueOf(templateObject.getEndLine()); endColumnNumber = Integer.valueOf(templateObject.getEndColumn()); } positionsCalculated = true; deleteFTLInstructionStackSnapshotIfNotNeeded(); } } }
e.setTemplateName(parentTemplate.getSourceName()); throw e;
@Override protected TemplateElement[] accept(Environment env) throws TemplateException, IOException { if (!DebuggerService.suspendEnvironment( env, this.getTemplate().getSourceName(), getChild(0).getBeginLine())) { return getChild(0).accept(env); } else { throw new StopException(env, "Stopped by debugger"); } }
e.setTemplateName(getSourceName()); throw e; } finally {
@Override public void handleTemplateException(TemplateException templateexception, Environment environment, Writer writer) throws TemplateException { try { String code = templateexception.getFTLInstructionStack(); if (null != code && code.indexOf("Failed at: ") > 0 && code.indexOf(" [") > 0) { writer.write("error:" + code.substring(code.indexOf("Failed at: ") + 11, code.indexOf(" ["))); } else { writer.write("[some errors occurred!]"); } } catch (IOException e) { log.error(environment.getCurrentTemplate().getSourceName(), e); } }
@Override public void handleTemplateException(TemplateException templateexception, Environment environment, Writer writer) throws TemplateException { try { String code = templateexception.getFTLInstructionStack(); if (null != code && code.indexOf("Failed at: ") > 0 && code.indexOf(" [") > 0) { writer.write("error:" + code.substring(code.indexOf("Failed at: ") + 11, code.indexOf(" ["))); } else { writer.write("[some errors occurred!]"); } } catch (IOException e) { log.error(environment.getCurrentTemplate().getSourceName(), e); } }
/** * @since 2.3.21 */ public ParseException(String description, Template template, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber, Throwable cause) { this(description, template == null ? null : template.getSourceName(), lineNumber, columnNumber, endLineNumber, endColumnNumber, cause); }
/** * @deprecated Use {@link #ParseException(String, Template, int, int, int, int, Throwable)} instead, as IDE-s need * the end position of the error too. * @since 2.3.20 */ @Deprecated public ParseException(String description, Template template, int lineNumber, int columnNumber, Throwable cause) { this(description, template == null ? null : template.getSourceName(), lineNumber, columnNumber, 0, 0, cause); }
/** * @deprecated Use {@link #ParseException(String, Template, int, int, int, int, Throwable)} instead, as IDE-s need * the end position of the error too. * @since 2.3.20 */ @Deprecated public ParseException(String description, Template template, int lineNumber, int columnNumber, Throwable cause) { this(description, template == null ? null : template.getSourceName(), lineNumber, columnNumber, 0, 0, cause); }
/** * @since 2.3.20 */ public ParseException(String description, TemplateObject tobj, Throwable cause) { this(description, tobj.getTemplate() == null ? null : tobj.getTemplate().getSourceName(), tobj.beginLine, tobj.beginColumn, tobj.endLine, tobj.endColumn, cause); }
/** * @since 2.3.20 */ public ParseException(String description, TemplateObject tobj, Throwable cause) { this(description, tobj.getTemplate() == null ? null : tobj.getTemplate().getSourceName(), tobj.beginLine, tobj.beginColumn, tobj.endLine, tobj.endColumn, cause); }
static String formatLocationForEvaluationError(Macro macro, int line, int column) { Template t = macro.getTemplate(); return formatLocation("at", t != null ? t.getSourceName() : null, macro.getName(), macro.isFunction(), line, column); }
@Override protected TemplateElement[] accept(Environment env) throws TemplateException, IOException { if (!DebuggerService.suspendEnvironment( env, this.getTemplate().getSourceName(), getChild(0).getBeginLine())) { return getChild(0).accept(env); } else { throw new StopException(env, "Stopped by debugger"); } }