Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected IllegalArgumentException using an inline template and a custom Writer #1070

Open
dpeterson-git opened this issue Jul 24, 2023 · 0 comments

Comments

@dpeterson-git
Copy link

dpeterson-git commented Jul 24, 2023

When compiling an inline template and supplying a custom Writer to the Template.apply method, an unexpected IllegalArgumentException can be thrown with the message "The error's column number must be greater than zero".

Handlebars handlebars = new Handlebars();
Template template = handlebars.compileInline("Hello {{user}}.");
template.apply("", null);

This produces the following stack trace:

java.lang.IllegalArgumentException: The error's column number must be greater than zero
	at org.apache.commons.lang3.Validate.isTrue(Validate.java:158)
	at com.github.jknack.handlebars.HandlebarsError.<init>(HandlebarsError.java:79)
	at com.github.jknack.handlebars.internal.BaseTemplate.apply(BaseTemplate.java:135)
	at com.github.jknack.handlebars.internal.ForwardingTemplate.apply(ForwardingTemplate.java:58)
	at HandlebarsTester.main(HandlebarsTester.java:115)

Yes the null Writer is not interesting and would not be used in practice, but it conveniently displays the issue. (One could imagine that the the real custom Writer ran out of space, or could not emit to a file, or was unable to send to a socket, etc.) The point is that this IllegalArgumentException should probably not be thrown when something unexpected happens with the Writer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant