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

Improve errors reporting of QuteProcessor #25724

Closed
angelozerr opened this issue May 23, 2022 · 2 comments · Fixed by #25810
Closed

Improve errors reporting of QuteProcessor #25724

angelozerr opened this issue May 23, 2022 · 2 comments · Fixed by #25810
Labels
area/kubernetes area/qute The template engine kind/enhancement New feature or request
Milestone

Comments

@angelozerr
Copy link

Description

When a quarkus application is build (with native or not), the step io.quarkus.qute.deployment.QuteProcessor#processTemplateErrors is very verbose and for IDE / Editor it is hard to capture those errors to display them in the IDE / Editors:

Here a sample of error:

[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:2.0.0.CR3:build (default) on project qute-panache: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkus.qute.deployment.QuteProcessor#processTemplateErrors threw an exception: io.quarkus.qute.TemplateException: Found template problems (2):
[ERROR] [1] Incorrect expression found: {item.name}
[ERROR]         - Only type-safe expressions are allowed in the checked template defined via: org.agoncal.article.qutepanache.BookPage$Templates.book(); an expression must be based on a checked template parameter [book], or bound via a param declaration, or the requirement must be relaxed via @CheckedTemplate(requireTypeSafeExpressions = false)
[ERROR]         - at BookPage/book.html:5
[ERROR] [2] Incorrect expression found: {book.isbnx}
[ERROR]         - property/method [isbnx] not found on class [org.agoncal.article.qutepanache.Book] nor handled by an extension method
[ERROR]         - at BookPage/books.html:22
[ERROR]         at io.quarkus.qute.deployment.QuteProcessor.processTemplateErrors(QuteProcessor.java:197)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR]         at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR]         Suppressed: io.quarkus.qute.TemplateException: Incorrect expression found: {item.name}
[ERROR]         - Only type-safe expressions are allowed in the checked template defined via: org.agoncal.article.qutepanache.BookPage$Templates.book(); an expression must be based on a checked template parameter [book], or bound via a param declaration, or the requirement must be relaxed via @CheckedTemplate(requireTypeSafeExpressions = false)
[ERROR]         - at BookPage/book.html:5
[ERROR]                 at io.quarkus.qute.deployment.QuteProcessor.processTemplateErrors(QuteProcessor.java:171)
[ERROR]                 ... 11 more
[ERROR]         Suppressed: io.quarkus.qute.TemplateException: Incorrect expression found: {book.isbnx}
[ERROR]         - property/method [isbnx] not found on class [org.agoncal.article.qutepanache.Book] nor handled by an extension method
[ERROR]         - at BookPage/books.html:22
[ERROR]                 at io.quarkus.qute.deployment.QuteProcessor.processTemplateErrors(QuteProcessor.java:177)
[ERROR]                 ... 11 more
[ERROR]
[ERROR]         [error]: Build step io.quarkus.kubernetes.deployment.KubernetesProcessor#build threw an exception: java.lang.NoSuchMethodError: 
'void org.yaml.snakeyaml.DumperOptions.setIndentWithIndicator(boolean)'
[ERROR]         at com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.buildDumperOptions(YAMLGenerator.java:307)
[ERROR]         at com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.<init>(YAMLGenerator.java:265)
[ERROR]         at com.fasterxml.jackson.dataformat.yaml.YAMLFactory._createGenerator(YAMLFactory.java:492)
[ERROR]         at com.fasterxml.jackson.dataformat.yaml.YAMLFactory.createGenerator(YAMLFactory.java:442)
[ERROR]         at com.fasterxml.jackson.dataformat.yaml.YAMLFactory.createGenerator(YAMLFactory.java:15)
[ERROR]         at com.fasterxml.jackson.databind.ObjectMapper.createGenerator(ObjectMapper.java:1164)
[ERROR]         at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3742)
[ERROR]         at io.dekorate.utils.Serialization.writeValueAsYamlSafe(Serialization.java:348)
[ERROR]         at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
[ERROR]         at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
[ERROR]         at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
[ERROR]         at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
[ERROR]         at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
[ERROR]         at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[ERROR]         at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
[ERROR]         at io.dekorate.utils.Serialization.asYaml(Serialization.java:111)
[ERROR]         at io.dekorate.processor.SimpleFileWriter.write(SimpleFileWriter.java:146)
[ERROR]         at io.dekorate.SessionWriter.lambda$write$1(SessionWriter.java:57)
[ERROR]         at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
[ERROR]         at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
[ERROR]         at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1746)
[ERROR]         at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
[ERROR]         at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
[ERROR]         at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
[ERROR]         at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
[ERROR]         at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[ERROR]         at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
[ERROR]         at io.dekorate.SessionWriter.write(SessionWriter.java:56)
[ERROR]         at io.dekorate.Session.close(Session.java:253)
[ERROR]         at io.quarkus.kubernetes.deployment.KubernetesProcessor.lambda$build$4(KubernetesProcessor.java:162)
[ERROR]         at java.base/java.util.Optional.ifPresent(Optional.java:183)
[ERROR]         at io.quarkus.kubernetes.deployment.KubernetesProcessor.build(KubernetesProcessor.java:120)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR]         at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:501)

Implementation ideas

It should be really nice to simplify the error reporting like https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher to have an error per line:

The previous sample generate an error like this:

helloWorld.c:5:3: warning: implicit declaration of function ‘prinft’

For Qute error, it could be become:

[ERROR] BookPage/books.html:22:0: error: Incorrect expression found: ‘{item.name}‘. Only type-safe expressions are allowed in the checked template defined via: org.agoncal.article.qutepanache.BookPage$Templates.book(); an expression must be based on a checked template parameter [book], or bound via a param declaration, or the requirement must be relaxed via @CheckedTemplate(requireTypeSafeExpressions = false)
[ERROR] BookPage/books.html:5:0: error:Incorrect expression found: ‘{book.isbnx}‘. Property/method [isbnx] not found on class [org.agoncal.article.qutepanache.Book] nor handled by an extension method

Instead of having:

[ERROR] [1] Incorrect expression found: {item.name}
[ERROR]         - Only type-safe expressions are allowed in the checked template defined via: org.agoncal.article.qutepanache.BookPage$Templates.book(); an expression must be based on a checked template parameter [book], or bound via a param declaration, or the requirement must be relaxed via @CheckedTemplate(requireTypeSafeExpressions = false)
[ERROR]         - at BookPage/book.html:5
[ERROR] [2] Incorrect expression found: {book.isbnx}
[ERROR]         - property/method [isbnx] not found on class [org.agoncal.article.qutepanache.Book] nor handled by an extension method
[ERROR]         - at BookPage/books.html:22
@angelozerr angelozerr added the kind/enhancement New feature or request label May 23, 2022
@quarkus-bot quarkus-bot bot added area/kubernetes area/qute The template engine labels May 23, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented May 23, 2022

/cc @geoand, @iocanel, @mkouba

@mkouba
Copy link
Contributor

mkouba commented May 26, 2022

Hm, the build output is primarily intended for developers not IDEs... so it should be concise but also readable. That said, we could improve the current message. @angelozerr How about something along these lines?

[ERROR]  Found incorrect expressions (2):
[ERROR]       [1] BookPage/book.html:5 - {item.name}: only type-safe expressions are allowed in the checked template defined via: org.agoncal.article.qutepanache.BookPage$Templates.book(); an expression must be based on a checked template parameter [book], or bound via a param declaration, or the requirement must be relaxed via @CheckedTemplate(requireTypeSafeExpressions = false)
[ERROR]       [2] BookPage/books.html:22 -  {book.isbnx}: property/method [isbnx] not found on class [org.agoncal.article.qutepanache.Book] nor handled by an extension method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubernetes area/qute The template engine kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants