StateNode#handleOnAttach exception message should be improved
See original GitHub issueI ran into this exception: https://github.com/vaadin/flow/blob/907cbbd59612ac2e31daf5c1566fb48529d75200/flow-server/src/main/java/com/vaadin/flow/internal/StateNode.java#L705-L706 When you get it, the stack trace gives you no hint what this is about:
Unexpected exception occured: java.lang.IllegalStateException: Can't change id once it has been ass
igned
at com.vaadin.flow.internal.StateNode.handleOnAttach(StateNode.java:705)
at com.vaadin.flow.internal.StateNode.lambda$onAttach$1(StateNode.java:312)
at com.vaadin.flow.internal.StateNode.visitNodeTreeBottomUp(StateNode.java:669)
at com.vaadin.flow.internal.StateNode.onAttach(StateNode.java:311)
at com.vaadin.flow.internal.StateNode.setParent(StateNode.java:270)
at com.vaadin.flow.internal.nodefeature.NodeFeature.attachPotentialChild(NodeFeature.java:78)
at com.vaadin.flow.internal.nodefeature.StateNodeNodeList.add(StateNodeNodeList.java:53)
at com.vaadin.flow.internal.nodefeature.ElementChildrenList.add(ElementChildrenList.java:42)
at com.vaadin.flow.dom.impl.AbstractNodeStateProvider.insertChild(AbstractNodeStateProvider.java:102)
at com.vaadin.flow.dom.Node.insertChild(Node.java:250)
at com.vaadin.flow.dom.Node.appendChild(Node.java:141)
at com.vaadin.flow.data.provider.AbstractComponentDataGenerator.registerRenderedComponent(AbstractComponentDataGenerator.java:128)
at com.vaadin.flow.data.provider.ComponentDataGenerator.generateData(ComponentDataGenerator.java:84)
at com.vaadin.flow.data.provider.CompositeDataGenerator.lambda$generateData$0(CompositeDataGenerator.java:47)
at java.lang.Iterable.forEach(Iterable.java:75)
at com.vaadin.flow.data.provider.CompositeDataGenerator.generateData(CompositeDataGenerator.java:47)
at com.vaadin.flow.data.provider.DataCommunicator.generateJson(DataCommunicator.java:660)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.IntPipeline$4$1.accept(IntPipeline.java:250)
at java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:110)
at java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:693)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
...
Expected behavior: it should at least tell, what kind of id is the problem.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
How to write a good exception message
All three items in this message I can work out from the rest of the exception. I know the class and method from...
Read more >Best Practices for exceptions - .NET - Microsoft Learn
Learn best practices for exceptions, such as using try/catch/finally, handling common conditions without exceptions, and using predefined .
Read more >How do I give streams better exception messages?
Boost is an open source project so the way I see it there are 2 options: Complain. Either write a bug report or...
Read more >8. Errors and Exceptions — Python 3.11.1 documentation
An exception could occur during execution of an except or else clause. Again, the exception is re-raised after the finally clause has been...
Read more >How to Raise Exceptions in Ruby - Rollbar
This method can be used to retrieve a specific exception message from a raised exception object. Raising Generic Exceptions. Like the title of ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@MathiasAugstein please note that 14.5 has been unsupported since May 2021 , I’d advice you to update to the latest minor version 14.7.
The exception is still throw in other case, but the text has been changed to give better hint, what is the likely cause so that it is easier to address the issue in application code.
OR, logging warning