Skip to content

Commit

Permalink
#39 fix error message for wrong param with precompiled classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
casid committed Dec 29, 2020
1 parent 7aabbd2 commit 8b77e7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ void params() {
assertThat(throwable).isInstanceOf(TemplateException.class).hasMessage("No parameter information is available for tag/unused.jte, compile templates with -parameters flag, to use this method.");
}

@Test
void paramWithWrongType() {
Throwable throwable = catchThrowable(() -> templateEngine.render("helloWorld.jte", Map.of("model", "string"), output));
assertThat(throwable).isInstanceOf(TemplateException.class).hasMessageContaining("Failed to render helloWorld.jte, error at helloWorld.jte:0");
}

private void whenTemplateIsRendered(String templateName) {
templateEngine.render(templateName, model, output);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ public DebugInfo resolveDebugInfo(ClassLoader classLoader, StackTraceElement[] s

private int resolveLineNumber(ClassInfo classInfo, int lineNumber) {
int[] javaLineToTemplateLine = classInfo.lineInfo;
return javaLineToTemplateLine[lineNumber - 1] + 1;
int lineIndex = lineNumber - 1;

if (lineIndex >= javaLineToTemplateLine.length) {
return 0;
}

return javaLineToTemplateLine[lineIndex] + 1;
}

protected TemplateType getTemplateType(String name) {
Expand Down

0 comments on commit 8b77e7c

Please sign in to comment.