This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch wicket-9.x
in repository https://gitbox.apache.org/repos/asf/wicket.git


The following commit(s) were added to refs/heads/wicket-9.x by this push:
     new fd91611d1d WICKET-7112 Expand error messages in Component class (#894)
fd91611d1d is described below

commit fd91611d1df8726e3b1836c045577baa09ff4cd1
Author: kbachl <[email protected]>
AuthorDate: Fri Jun 21 10:08:00 2024 +0200

    WICKET-7112 Expand error messages in Component class (#894)
    
    * Expand error messages in Component class
    
    The error messages in the Component class have been augmented with more 
detailed information. These include class type, parent markup ID, parent 
relative path, and the original URL. This is to give a more comprehensive 
context surrounding the error, aiding debugging and issue resolution.
    
    * Refactor error messages for markup components
    
    The error messages in the Component class have been simplified by removing 
details about the parent markup ID, parent relative path, and original URL. 
Instead, the focus is now on the component's page class and relative path. The 
associated test has been adjusted to reflect these changes.
    
    * WICKET-7112 Improve log message
    
    ---------
    
    Co-authored-by: Martin Grigorov <[email protected]>
---
 wicket-core/src/main/java/org/apache/wicket/Component.java          | 6 ++++--
 .../settings/ExceptionSettingsNotRenderableErrorStrategyTest.java   | 5 +++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java 
b/wicket-core/src/main/java/org/apache/wicket/Component.java
index 1b2fe94cb0..ea7d3a3e6f 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -2478,7 +2478,8 @@ public abstract class Component
                                if (getFlag(FLAG_OUTPUT_MARKUP_ID))
                                {
                                        String message = String.format("Markup 
id set on a component that renders its body only. " +
-                                                                      "Markup 
id: %s, component id: %s.", getMarkupId(), getId());
+                                                                      "Markup 
id: %s, component id: %s, type: %s, path: %s",
+                                                       getMarkupId(), getId(), 
getClass(), getPage().getPageClass() + ":" + getPageRelativePath());
                                        if (notRenderableErrorStrategy == 
ExceptionSettings.NotRenderableErrorStrategy.THROW_EXCEPTION)
                                        {
                                                throw new 
IllegalStateException(message);
@@ -2488,7 +2489,8 @@ public abstract class Component
                                if (getFlag(FLAG_PLACEHOLDER))
                                {
                                        String message = 
String.format("Placeholder tag set on a component that renders its body only. " 
+
-                                                                      
"Component id: %s.", getId());
+                                                                      
"Component id: %s, type: %s, path: %s\", ",
+                                                       getId(), getClass(), 
getPage().getPageClass() + ":" + getPageRelativePath());
                                        if (notRenderableErrorStrategy == 
ExceptionSettings.NotRenderableErrorStrategy.THROW_EXCEPTION)
                                        {
                                                throw new 
IllegalStateException(message);
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/settings/ExceptionSettingsNotRenderableErrorStrategyTest.java
 
b/wicket-core/src/test/java/org/apache/wicket/settings/ExceptionSettingsNotRenderableErrorStrategyTest.java
index 169b7e3852..96d7e5c1dc 100644
--- 
a/wicket-core/src/test/java/org/apache/wicket/settings/ExceptionSettingsNotRenderableErrorStrategyTest.java
+++ 
b/wicket-core/src/test/java/org/apache/wicket/settings/ExceptionSettingsNotRenderableErrorStrategyTest.java
@@ -115,8 +115,9 @@ class ExceptionSettingsNotRenderableErrorStrategyTest 
extends WicketTestCase {
     }
 
     private void assertRenderBodyOnlyException(final WicketRuntimeException 
wrx) {
-        assertThat(wrx.getCause().getMessage(), is(equalTo("Markup id set on a 
component that renders its "
-                                                           + "body only. 
Markup id: test1, component id: test.")));
+        assertThat(wrx.getCause().getMessage(), is(equalTo("Markup id set on a 
component that renders its body only. " +
+                "Markup id: test1, component id: test, type: class 
org.apache.wicket.markup.html.basic.Label, " +
+                "path: class 
org.apache.wicket.settings.ExceptionSettingsNotRenderableErrorStrategyTest$RenderBodyOnlyTestPage:test")));
     }
 
     private static class WicketTagTestPage extends WebPage implements 
IMarkupResourceStreamProvider

Reply via email to