use of org.grails.gsp.GroovyPagesException in project grails-core by grails.
the class GroovyPageView method createGroovyPageException.
public static GroovyPagesException createGroovyPageException(Exception exception, GroovyPagesTemplateEngine engine, String pageUrl) {
GroovyPageTemplate t = (GroovyPageTemplate) engine.createTemplate(pageUrl);
StackTraceElement[] stackTrace = exception.getStackTrace();
String className = stackTrace[0].getClassName();
int lineNumber = stackTrace[0].getLineNumber();
if (className.contains("_gsp")) {
int[] lineNumbers = t.getMetaInfo().getLineNumbers();
if (lineNumber < lineNumbers.length) {
lineNumber = lineNumbers[lineNumber - 1];
}
}
Resource resource = pageUrl != null ? engine.getResourceForUri(pageUrl) : null;
String file;
try {
file = resource != null && resource.exists() ? resource.getFile().getAbsolutePath() : pageUrl;
} catch (IOException e) {
file = pageUrl;
}
return new GroovyPagesException("Error processing GroovyPageView: " + exception.getMessage(), exception, lineNumber, file);
}
Aggregations