Comment 0 for bug 478315

Revision history for this message
tomas (gugljafa) wrote :

I had several problems in my view, including #(if..} instead of #{if..} and instead of seeing the description of the problem in the browser, I got 'Application error, check logs', here is the exception:
Template execution error (In /app/views/errors/500.html around line 18)
Execution error occured in template /app/views/errors/500.html. Exception raised was IndexOutOfBoundsException : toIndex = 52.

play.exceptions.TemplateExecutionException: toIndex = 52
        at play.templates.Template.throwException(Template.java:263)
        at play.templates.Template.render(Template.java:228)
        at play.server.HttpHandler.serve500(HttpHandler.java:348)
        at Invocation.HTTP Request(Play!)
Caused by: java.lang.IndexOutOfBoundsException: toIndex = 52
        at java.util.SubList.<init>(AbstractList.java:602)
        at java.util.RandomAccessSubList.<init>(AbstractList.java:758)
        at java.util.AbstractList.subList(AbstractList.java:468)
        at /app/views/errors/500.html.(line:18)
        at play.templates.Template.render(Template.java:208)
        ... 2 more

This happened because groovy can pick up wrong line number, in my case it was greater than the number of lines in the file. Replacing line 98 in file 500.html with this fixes the problem - the whole template file would be shown:
from = exception.lineNumber - 5 >= 0 && exception.lineNumber -5 < exception.source.size() ? exception.lineNumber - 5 : 0

Also, on line 105, the 'line' should be escaped:
                    <pre>&nbsp;${line.escapeHtml()}</pre>

I am using r.671
thanks