From 419a8b887ce55b010f861b7ee8854c59aadecb7b Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 13 Apr 2011 14:41:49 -0700 Subject: [PATCH] Fixed typo; restrict exception handling to just the loading of a partial template; pass runtime exceptions through unwrapped. --- src/main/java/com/samskivert/mustache/Mustache.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/samskivert/mustache/Mustache.java b/src/main/java/com/samskivert/mustache/Mustache.java index 79e7b72..0f6531e 100644 --- a/src/main/java/com/samskivert/mustache/Mustache.java +++ b/src/main/java/com/samskivert/mustache/Mustache.java @@ -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; }