Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
Catch and log runtime ST4 errors (not just loader errors)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcox committed Jul 10, 2014
1 parent 1edc68d commit a743629
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -52,7 +52,7 @@ public InputSupplier<InputStreamReader> apply(@Nonnull String templateFileName)

private static final Logger LOG = LoggerFactory.getLogger(TemplateLoader.class);

private final STErrorListener ERROR_LISTENER = new LoaderErrorListener();
private final STErrorListener ERROR_LISTENER = new ErrorListener();

private final Iterable<String> templateFileNames;
private volatile STGroup stg = null;
Expand Down Expand Up @@ -85,6 +85,7 @@ protected STGroup getTemplateGroup(Iterable<String> templateFileNames) throws IO

// Combine the header and all .st files and load everything into a StringTemplateGroup
stg = new STGroup();
stg.setListener(ERROR_LISTENER);
for (String templateFileName : templateFileNames) {
stg.importTemplates(getTemplateGroupFromFile(templateFileName));
}
Expand All @@ -107,7 +108,7 @@ protected STGroup getTemplateGroupFromFile(String fileName) throws IOException
return stg;
}

private static class LoaderErrorListener implements STErrorListener
private static class ErrorListener implements STErrorListener
{
@Override
public void compileTimeError(STMessage msg)
Expand Down

0 comments on commit a743629

Please sign in to comment.