return null if no template could be found

This commit is contained in:
Sebastian Sdorra
2012-08-18 12:02:07 +02:00
parent 428b7973fe
commit ff362ead93
3 changed files with 127 additions and 7 deletions

View File

@@ -37,6 +37,7 @@ package sonia.scm.template;
import com.github.mustachejava.Mustache;
import com.google.common.util.concurrent.UncheckedExecutionException;
import com.google.inject.Inject;
import org.slf4j.Logger;
@@ -104,20 +105,47 @@ public class MustacheTemplateEngine implements TemplateEngine
}
Template template = null;
Mustache mustache = factory.compile(templatePath);
if (mustache != null)
try
{
if (logger.isTraceEnabled())
Mustache mustache = factory.compile(templatePath);
if (mustache != null)
{
logger.trace("return mustache template for {}", templatePath);
if (logger.isTraceEnabled())
{
logger.trace("return mustache template for {}", templatePath);
}
template = new MustacheTemplate(templatePath, mustache);
}
else if (logger.isWarnEnabled())
{
logger.warn("could not find mustache template at {}", templatePath);
}
template = new MustacheTemplate(templatePath, mustache);
}
else if (logger.isWarnEnabled())
catch (MustacheTemplateNotFoundException ex)
{
logger.warn("could not find mustache template at {}", templatePath);
if (logger.isWarnEnabled())
{
logger.warn("could not find mustache template at {}", templatePath);
}
}
catch (UncheckedExecutionException ex)
{
if (ex.getCause() instanceof MustacheTemplateNotFoundException)
{
if (logger.isWarnEnabled())
{
logger.warn("could not find mustache template at {}", templatePath);
}
else
{
throw ex;
}
}
}
return template;