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:
@@ -134,9 +134,9 @@ public class Template
|
||||
Object data = getValue(ctx, comps[0].intern(), line, missingIsNull);
|
||||
for (int ii = 1; ii < comps.length; ii++) {
|
||||
if (data == NO_FETCHER_FOUND) {
|
||||
if (!missingIsNull) throw new MustacheException(
|
||||
if (!missingIsNull) throw new MustacheContextException(
|
||||
"Missing context for compound variable '" + name + "' on line " + line +
|
||||
". '" + comps[ii - 1] + "' was not found.");
|
||||
". '" + comps[ii - 1] + "' was not found.", name, line);
|
||||
return null;
|
||||
} else if (data == null) {
|
||||
return null;
|
||||
@@ -231,8 +231,8 @@ public class Template
|
||||
_fcache.put(key, fetcher);
|
||||
return value;
|
||||
} catch (Exception e) {
|
||||
throw new MustacheException(
|
||||
"Failure fetching variable '" + name + "' on line " + line, e);
|
||||
throw new MustacheContextException(
|
||||
"Failure fetching variable '" + name + "' on line " + line, name, line, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,8 +240,8 @@ public class Template
|
||||
{
|
||||
if (value == NO_FETCHER_FOUND) {
|
||||
if (missingIsNull) return null;
|
||||
throw new MustacheException(
|
||||
"No method or field with name '" + name + "' on line " + line);
|
||||
throw new MustacheContextException(
|
||||
"No method or field with name '" + name + "' on line " + line, name, line);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user