This feature is not currently supported. As a workaround you can wrap a script with an additional janino query and catch the exception there. A root cause needs to be unwrapped by walking through the chain of exceptions causing the error:
<connection id="db" url="jdbc:hsqldb:mem:test"/>
<connection id="java" driver="janino"/>
<query connection-id="java">
try {
next();
} catch( Exception e ) {
System.out.println("Error: "+e);
System.out.println("Cause: "+e.getCause());
//May need to walk deeper up to the root cause
e.printStackTrace();
}
<script connection-id="db">
SYNTAX ERROR
</script>
</query>
I plan to add support for switching of connection-id in the <onerror> element and exposing the error details as object, so something like this should become possible:
<script>
ERROR STATEMENT;
<onerror connection-id="text">
</onerror>
</script>