Added MustacheContextException

Solving need to distinguish context errors from environment errors.
  The exception has fields for the offending key and line number. This
  is a first step towards internationalization of messages.
This commit is contained in:
pmenhart
2013-03-05 23:33:48 -05:00
parent f3afcda74f
commit c61650734d
4 changed files with 40 additions and 13 deletions
@@ -609,8 +609,8 @@ public class Mustache
@Override public void execute (Template tmpl, Template.Context ctx, Writer out) {
Object value = tmpl.getValueOrDefault(ctx, _name, _line);
if (value == null) {
throw new MustacheException(
"No key, method or field with name '" + _name + "' on line " + _line);
throw new MustacheContextException(
"No key, method or field with name '" + _name + "' on line " + _line, _name, _line);
}
String text = String.valueOf(value);
write(out, _escapeHTML ? escapeHTML(text) : text);