/** * Return our custum message if we have one, else return the default message */ public String getMessage() { if (msg != null) return msg; return super.getMessage(); } }
/** * Return our custom message if we have one, else return the default message */ public String getMessage() { if (msg != null) return msg; return super.getMessage(); } }
/** * @see Exception#getMessage() * @since 1.5 */ public String getMessage() { StringBuffer message = new StringBuffer(); message.append(super.getMessage()); message.append(" at "); message.append(Log.formatFileString(templateName, lineNumber, columnNumber)); return message.toString(); } }
/** * @see Exception#getMessage() * @since 1.5 */ public String getMessage() { StringBuilder message = new StringBuilder(); message.append(super.getMessage()); message.append(" at "); message.append(StringUtils.formatFileString(templateName, lineNumber, columnNumber)); return message.toString(); } }
/** * @see Exception#getMessage() * @since 1.5 */ public String getMessage() { StringBuffer message = new StringBuffer(); message.append(super.getMessage()); message.append(" at "); message.append(Log.formatFileString(templateName, lineNumber, columnNumber)); return message.toString(); } }
private void displayLinesInError(VelocityException exception, TemplatePack templatePack, Template template) { try { Scanner scanner = new Scanner(exception.getMessage()); String match = scanner.findInLine("\\[line (\\d+), column (\\d+)\\]"); if (match == null) { return; } MatchResult result = scanner.match(); int lineInError = parseInt(result.group(1)); int column = parseInt(result.group(2)); String[] lines = template.getTemplate().split("\\n"); int linesBeforeToDisplay = 2; int linesAfterToDisplay = 2; for (int i = max(0, lineInError - linesBeforeToDisplay); i < lineInError; i++) { System.err.println(prefix(templatePack, template, i + 1) + lines[i]); } String prefix = prefix(templatePack, template, lineInError); System.err.print(prefix); for (int i = 0; i < column - 1; i++) { System.err.print(" "); } System.err.println("^"); for (int i = lineInError; i < min(lines.length - 1, lineInError + linesAfterToDisplay); i++) { System.err.println(prefix(templatePack, template, i + 1) + lines[i]); } } catch (Exception e) { e.printStackTrace(); } }
private void displayLinesInError(VelocityException exception, TemplatePack templatePack, Template template) { try { Scanner scanner = new Scanner(exception.getMessage()); String match = scanner.findInLine("\\[line (\\d+), column (\\d+)\\]"); if (match == null) { return; } MatchResult result = scanner.match(); int lineInError = parseInt(result.group(1)); int column = parseInt(result.group(2)); String[] lines = template.getTemplate().split("\\n"); int linesBeforeToDisplay = 2; int linesAfterToDisplay = 2; for (int i = max(0, lineInError - linesBeforeToDisplay); i < lineInError; i++) { System.err.println(prefix(templatePack, template, i + 1) + lines[i]); } String prefix = prefix(templatePack, template, lineInError); System.err.print(prefix); for (int i = 0; i < column - 1; i++) { System.err.print(" "); } System.err.println("^"); for (int i = lineInError; i < min(lines.length - 1, lineInError + linesAfterToDisplay); i++) { System.err.println(prefix(templatePack, template, i + 1) + lines[i]); } } catch (Exception e) { e.printStackTrace(); } }
/** * Send a simple message based on a Velocity template. * @param msg the message to populate * @param templateName the Velocity template to use (relative to classpath) * @param model a map containing key/value pairs */ @SuppressWarnings("unchecked") public void sendMessage(SimpleMailMessage msg, String templateName, Map model) { String result = null; try { result = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, templateName, "UTF-8", model); } catch (VelocityException e) { e.printStackTrace(); log.error(e.getMessage()); } msg.setText(result); send(msg); }
templateName, model); } catch (VelocityException e) { log.error(e.getMessage());
throw new MessageBuilderException("Building Velocity message failed: " + e.getMessage(), e); } catch (BooleanFunctionException e) { throw new MessageBuilderException("Building message failed: " + e.getMessage(), e);
throw new MessageBuilderException("Building Velocity message failed: " + e.getMessage(), e); } catch (BooleanFunctionException e) { throw new MessageBuilderException("Building message failed: " + e.getMessage(), e);
/** * Create a ParseErrorException with the given ParseException. * * @param pex the parsing exception * @since 1.5 */ public ParseErrorException(VelocityException pex) { super(pex.getMessage()); // Don't use a second C'tor, TemplateParseException is a subclass of // ParseException... if (pex instanceof ExtendedParseException) { ExtendedParseException xpex = (ExtendedParseException) pex; columnNumber = xpex.getColumnNumber(); lineNumber = xpex.getLineNumber(); templateName = xpex.getTemplateName(); } else if (pex.getWrappedThrowable() instanceof ParseException) { ParseException pex2 = (ParseException) pex.getWrappedThrowable(); if (pex2.currentToken != null && pex2.currentToken.next != null) { columnNumber = pex2.currentToken.next.beginColumn; lineNumber = pex2.currentToken.next.beginLine; } } }
/** * Create a ParseErrorException with the given ParseException. * * @param pex the parsing exception * @since 1.5 */ public ParseErrorException(VelocityException pex, String templName) { super(pex.getMessage()); if (templName != null) templateName = templName; // Don't use a second C'tor, TemplateParseException is a subclass of // ParseException... if (pex instanceof ExtendedParseException) { ExtendedParseException xpex = (ExtendedParseException) pex; columnNumber = xpex.getColumnNumber(); lineNumber = xpex.getLineNumber(); templateName = xpex.getTemplateName(); } else if (pex.getCause() instanceof ParseException) { ParseException pex2 = (ParseException) pex.getCause(); if (pex2.currentToken != null && pex2.currentToken.next != null) { columnNumber = pex2.currentToken.next.beginColumn; lineNumber = pex2.currentToken.next.beginLine; } } }
/** * Create a ParseErrorException with the given ParseException. * * @param pex the parsing exception * @since 1.5 */ public ParseErrorException(VelocityException pex, String templName) { super(pex.getMessage()); if (templName != null) templateName = templName; // Don't use a second C'tor, TemplateParseException is a subclass of // ParseException... if (pex instanceof ExtendedParseException) { ExtendedParseException xpex = (ExtendedParseException) pex; columnNumber = xpex.getColumnNumber(); lineNumber = xpex.getLineNumber(); templateName = xpex.getTemplateName(); } else if (pex.getWrappedThrowable() instanceof ParseException) { ParseException pex2 = (ParseException) pex.getWrappedThrowable(); if (pex2.currentToken != null && pex2.currentToken.next != null) { columnNumber = pex2.currentToken.next.beginColumn; lineNumber = pex2.currentToken.next.beginLine; } } }
+ " as a Velocity template: " + e.getMessage(), e );