throw io exception if template is not parse able

This commit is contained in:
Sebastian Sdorra
2012-08-18 13:52:17 +02:00
parent 6cae6a8910
commit 9de33362bd
7 changed files with 159 additions and 5 deletions

View File

@@ -37,6 +37,7 @@ package sonia.scm.template;
import com.github.mustachejava.Mustache;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.UncheckedExecutionException;
import com.google.inject.Inject;
@@ -135,17 +136,29 @@ public class MustacheTemplateEngine implements TemplateEngine
}
catch (UncheckedExecutionException ex)
{
if (ex.getCause() instanceof MustacheTemplateNotFoundException)
Throwable cause = ex.getCause();
if (cause instanceof MustacheTemplateNotFoundException)
{
if (logger.isWarnEnabled())
{
logger.warn("could not find mustache template at {}", templatePath);
}
else
{
throw ex;
}
}
else
{
Throwables.propagateIfInstanceOf(cause, IOException.class);
throw new TemplateParseException(
"could not parse template for resource ".concat(templatePath), cause);
}
}
catch (Exception ex)
{
Throwables.propagateIfInstanceOf(ex, IOException.class);
throw new TemplateParseException(
"could not parse template for resource ".concat(templatePath), ex);
}
return template;