brianm/jdbi — pull request #95 by jaredstehler (2014-03-18 15:43:49+00:00)
Title: allow alternate StringTemplateErrorListener in statement locator

The default error listener simply logs a stack trace to system.err; it would definitely be useful to be able to supply a custom error listener, which would propagate errors such as invalid syntax, etc.

I ran into an issue the other day where I had queries in a DAO with unmatched '<' (as in doing a date comparison) and the stringtemplate parser was choking on a missing '>' but swallowing the error and leaving me with a truncated query string instead.

Here's what I would love to have as an error listener:
```java
public class PropagatingStringTemplateErrorListener implements StringTemplateErrorListener {
private static final Logger LOG = LoggerFactory.getLogger(PropagatingStringTemplateErrorListener.class);

@Override
public void error(String msg, Throwable e) {
LOG.error(msg, e);
throw Throwables.propagate(e);
}

@Override
public void warning(String msg) {
LOG.warn(msg);
}
}
```

with this change, I could update my DAO's annotation as such:
```java
@UseStringTemplate3StatementLocator(errorListener=PropagatingStringTemplateErrorListener.class)
```

An alternative to this could be to have a static error listener defined in the StringTemplate3StatementLocator builder class..?