Modify

Ticket #41 (new task)

Opened 4 years ago

Last modified 3 years ago

Error handling in template engine

Reported by: jgou Owned by: jgou
Priority: minor Milestone: 0.5
Component: universe/kauri-template Version: trunk
Keywords: Cc:

Description

So far little effort has been put in error handling in the kauri template engine.
We should think about a useful strategy such as 'failfast' and do a decent implementation of it.

Attachments

Change History

comment:1 Changed 4 years ago by mpo

Another aspect of this error-handling is decent reporting of location (filename, line and column) of the tags ans expressions leading to the exception.

juel seems to do it's share:
Caused by: javax.el.ELException: Error parsing '${publicUri(km:/sample-data')}': syntax error at position 14, encountered ':', expected ')'

but in this case I'm left to wonder in which file at what position this expression is to be found

comment:2 Changed 4 years ago by bruno

I would suggest using the technique of a callback interface for reporting errors, warnings and other messages. This way, the error handling is not hardcoded. This can also remove the need for a dependency on a logging library in the template engine.

There are examples around of this technique, e.g. org.xml.sax.ErrorHandler.

A rather generic design for such an interface could be:

interface ErrorHandler {
    void fatalError(String message);

    void fatalError(String message, Throwable t);

    void warning(String message);

    void warning(String message, Throwable t);

    void info(String message);
}

Though we could also consider more fine-grained methods for cases where we're not sure what to do. For example, is an error in an expression fatal or not? This could be solved by having methods like

    void expressionCompilationError(String expression, Location location, String message, Throwable t);

While at it, here's a (non-exhaustive) list of places I've noticed that need error handling improvements:

  • ELFacade
  • DefaultTemplateBuilder.buildTemplate
  • DefaultTemplateBuilder: reporting of "Unsupported KTL directive"
  • TemplateExecutor

comment:3 Changed 3 years ago by mpo

  • Milestone changed from 0.3 to 0.4

during 0.4 this could get more detail/concrete fill in of what actually to do
actual implementation probably for post 0.4 though

comment:4 Changed 3 years ago by mpo

see also #191

comment:5 Changed 3 years ago by mpo

  • Milestone changed from 0.4 to 0.5

Should be tackled together with more templating work as it comes along

View

Add a comment

Modify Ticket

Action
as new
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.