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

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


The following commit(s) were added to refs/heads/master by this push:
     new 7c400a2f14 WICKET-7112 Expand error messages in Component class (#894)
7c400a2f14 is described below

commit 7c400a2f146105401e01f8d2d2975c848f5d8cb4
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]>
    (cherry picked from commit fd91611d1df8726e3b1836c045577baa09ff4cd1)
---
 .../settings/ExceptionSettingsNotRenderableErrorStrategyTest.java   | 5 +++--
 wicket-core/src/main/java/org/apache/wicket/Component.java          | 6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git 
a/wicket-core-tests/src/test/java/org/apache/wicket/settings/ExceptionSettingsNotRenderableErrorStrategyTest.java
 
b/wicket-core-tests/src/test/java/org/apache/wicket/settings/ExceptionSettingsNotRenderableErrorStrategyTest.java
index 169b7e3852..96d7e5c1dc 100644
--- 
a/wicket-core-tests/src/test/java/org/apache/wicket/settings/ExceptionSettingsNotRenderableErrorStrategyTest.java
+++ 
b/wicket-core-tests/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
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 ac1c93b5e8..5b695089bd 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);

Reply via email to