Fixed typo; restrict exception handling to just the loading of a partial

template; pass runtime exceptions through unwrapped.
This commit is contained in:
Michael Bayne
2011-04-13 14:41:49 -07:00
parent 0959ccd0d9
commit 419a8b887c
@@ -386,14 +386,20 @@ public class Mustache
protected static class IncludedTemplateSegment extends Template.Segment {
public IncludedTemplateSegment (final String templateName, final Compiler compiler) {
Reader r;
try {
_template = compiler.compile(compiler.loader.getTemplate(templateName));
r = compiler.loader.getTemplate(templateName);
} catch (Exception e) {
throw new MustacheException("Unable to load template: " + templateName, e);
if (e instanceof RuntimeException) {
throw (RuntimeException)e;
} else {
throw new MustacheException("Unable to load template: " + templateName, e);
}
}
_template = compiler.compile(r);
}
@Override public void execute (Template tmpl, Template.Context ctx, Writer out) {
template.execute(ctx.data, out);
_template.execute(ctx.data, out);
}
protected final Template _template;
}