This is an automated email from the ASF dual-hosted git repository.
reiern70 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 3504ce03e1 [WICKET-7050] make DefaultExceptionMapper more configurable
for the case an exception happens while original exception is mapped.
3504ce03e1 is described below
commit 3504ce03e1628449f633b1afcd2a63840e91139f
Author: reiern70 <[email protected]>
AuthorDate: Wed Apr 19 09:30:18 2023 +0300
[WICKET-7050] make DefaultExceptionMapper more configurable for the case an
exception happens while original exception is mapped.
---
.../org/apache/wicket/DefaultExceptionMapper.java | 33 +++++++++++++++-------
1 file changed, 23 insertions(+), 10 deletions(-)
diff --git
a/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
b/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
index b2a065579d..a26a882c43 100644
--- a/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/DefaultExceptionMapper.java
@@ -63,17 +63,30 @@ public class DefaultExceptionMapper implements
IExceptionMapper
}
catch (RuntimeException e2)
{
- if (logger.isDebugEnabled())
- {
- logger.error(
- "An error occurred while handling a
previous error: " + e2.getMessage(), e2);
- }
+ return handleNestedException(e, e2);
+ }
+ }
+
- // hmmm, we were already handling an exception! give up
- logger.error("unexpected exception when handling
another exception: " + e.getMessage(),
- e);
- return new ErrorCodeRequestHandler(500);
+ /**
+ * Handles the case when an exception is generated while mapping the
original exception happened
+ *
+ * @param originalException The original exception.
+ * @param nestedException The nested (second) exception produced
+ * @return IRequestHandler (by default ErrorCodeRequestHandler
+ */
+ protected IRequestHandler handleNestedException(Exception
originalException, RuntimeException nestedException)
+ {
+ if (logger.isDebugEnabled())
+ {
+ logger.error(
+ "An error occurred while handling a
previous error: " + nestedException.getMessage(), nestedException);
}
+
+ // hmmm, we were already handling an exception! give up
+ logger.error("unexpected exception when handling another
exception: " + originalException.getMessage(),
+ originalException);
+ return new ErrorCodeRequestHandler(500);
}
/**
@@ -187,7 +200,7 @@ public class DefaultExceptionMapper implements
IExceptionMapper
/**
* Creates a {@link RenderPageRequestHandler} for the target page
provided by {@code pageProvider}.
- *
+ * <p>
* Uses {@link RenderPageRequestHandler.RedirectPolicy#NEVER_REDIRECT}
policy to preserve the original page's URL
* for non-Ajax requests and {@link
RenderPageRequestHandler.RedirectPolicy#AUTO_REDIRECT} for AJAX requests.
*