Repository: wicket
Updated Branches:
  refs/heads/wicket-7.x 87fa74899 -> 2c570edf0


WICKET-6240 Hook method to display more information on ExceptionErrorPage


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/2c570edf
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/2c570edf
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/2c570edf

Branch: refs/heads/wicket-7.x
Commit: 2c570edf028cf20ef573e45853692da1c00f4b5a
Parents: 87fa748
Author: Martin Tzvetanov Grigorov <mgrigo...@apache.org>
Authored: Tue Sep 20 21:59:23 2016 +0200
Committer: Martin Tzvetanov Grigorov <mgrigo...@apache.org>
Committed: Tue Sep 20 22:01:18 2016 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/wicket/Application.java |  7 ++++++-
 .../request/cycle/IRequestCycleListener.java     | 16 ++++++++++------
 .../wicket/settings/ApplicationSettings.java     | 19 ++++++++++++-------
 .../apache/wicket/request/IExceptionMapper.java  |  3 +++
 4 files changed, 31 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/2c570edf/wicket-core/src/main/java/org/apache/wicket/Application.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Application.java 
b/wicket-core/src/main/java/org/apache/wicket/Application.java
index 0df8caf..22a9971 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Application.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Application.java
@@ -850,7 +850,12 @@ public abstract class Application implements 
UnboundListener, IEventSink
        }
 
        /**
-        * @return the exception mapper provider
+        * Returns a supplier of {@link IExceptionMapper} that will be used to
+        * handle exceptions which were not handled by any
+        * {@link IRequestCycleListener#onException(RequestCycle, Exception) 
request cycle listener}.
+        *
+        * @return the exception mapper supplier
+        * @see IRequestCycleListener#onException(RequestCycle, Exception)
         */
        public IProvider<IExceptionMapper> getExceptionMapperProvider()
        {

http://git-wip-us.apache.org/repos/asf/wicket/blob/2c570edf/wicket-core/src/main/java/org/apache/wicket/request/cycle/IRequestCycleListener.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/request/cycle/IRequestCycleListener.java
 
b/wicket-core/src/main/java/org/apache/wicket/request/cycle/IRequestCycleListener.java
index a755e67..74574ec 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/request/cycle/IRequestCycleListener.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/request/cycle/IRequestCycleListener.java
@@ -144,15 +144,19 @@ public interface IRequestCycleListener
         * 
         * Note that in the event of an exception, {@link 
#onEndRequest(RequestCycle)} will still be called after
         * these listeners have {@link #onException(RequestCycle, Exception)} 
called
-        * 
-        * @param cycle
-        * 
-        * @return request handler that will be executed or {@code null} if 
none. If a request handler
-        *         is returned, it will override any configured exception mapper
-        * 
+        * <p>
+        * <strong>Important</strong>: Custom implementations are recommended 
to <strong>not</strong> try to
+        * handle exceptions implementing {@link 
org.apache.wicket.IWicketInternalException} interface.
+        * Usually such kind of exceptions should be handled by the framework.
+        * </p>
+        *
+        * @param cycle The current {@link RequestCycle request cycle}
         * @param ex
         *            the exception that was passed in to
         *            {@link RequestCycle#handleException(Exception)}
+        * @return request handler that will be executed or {@code null} if 
none. If a request handler
+        *         is returned, it will override any configured
+        *         {@link Application#getExceptionMapperProvider() exception 
mapper}.
         */
        IRequestHandler onException(RequestCycle cycle, Exception ex);
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/2c570edf/wicket-core/src/main/java/org/apache/wicket/settings/ApplicationSettings.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/settings/ApplicationSettings.java 
b/wicket-core/src/main/java/org/apache/wicket/settings/ApplicationSettings.java
index 52be4f6..3dc699d 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/settings/ApplicationSettings.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/settings/ApplicationSettings.java
@@ -23,6 +23,7 @@ import org.apache.wicket.application.DefaultClassResolver;
 import org.apache.wicket.application.IClassResolver;
 import org.apache.wicket.feedback.DefaultCleanupFeedbackMessageFilter;
 import org.apache.wicket.feedback.IFeedbackMessageFilter;
+import org.apache.wicket.request.cycle.RequestCycle;
 import org.apache.wicket.util.lang.Args;
 import org.apache.wicket.util.lang.Bytes;
 
@@ -172,18 +173,25 @@ public class ApplicationSettings
        }
 
        /**
-        * Sets internal error page class. The class must be bookmarkable and 
must extend Page.
+        * Sets internal error page class. The class must be bookmarkable and 
must extend {@link Page}.
+        *
+        * <p>Consider using custom
+        * {@link 
org.apache.wicket.request.cycle.IRequestCycleListener#onException(RequestCycle, 
Exception) request
+        * cycle listener} if you need to pass some extra information to the 
error page. By using
+        * {@link org.apache.wicket.request.cycle.IRequestCycleListener} the 
application has more flexibility in
+        * the instantiation of the error page.</p>
         *
         * @param internalErrorPage
         *            The internalErrorPage to set.
         * @return {@code this} object for chaining
+        * @see 
org.apache.wicket.request.cycle.IRequestCycleListener#onException(RequestCycle, 
Exception)
         */
        public ApplicationSettings setInternalErrorPage(final Class<? extends 
Page> internalErrorPage)
        {
                Args.notNull(internalErrorPage, "internalErrorPage");
                checkPageClass(internalErrorPage);
 
-               this.internalErrorPage = new WeakReference<Class<? extends 
Page>>(internalErrorPage);
+               this.internalErrorPage = new WeakReference<>(internalErrorPage);
                return this;
        }
 
@@ -196,13 +204,10 @@ public class ApplicationSettings
         */
        public ApplicationSettings setPageExpiredErrorPage(final Class<? 
extends Page> pageExpiredErrorPage)
        {
-               if (pageExpiredErrorPage == null)
-               {
-                       throw new IllegalArgumentException("Argument 
pageExpiredErrorPage may not be null");
-               }
+               Args.notNull(pageExpiredErrorPage, "pageExpiredErrorPage");
                checkPageClass(pageExpiredErrorPage);
 
-               this.pageExpiredErrorPage = new WeakReference<Class<? extends 
Page>>(pageExpiredErrorPage);
+               this.pageExpiredErrorPage = new 
WeakReference<>(pageExpiredErrorPage);
                return this;
        }
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/2c570edf/wicket-request/src/main/java/org/apache/wicket/request/IExceptionMapper.java
----------------------------------------------------------------------
diff --git 
a/wicket-request/src/main/java/org/apache/wicket/request/IExceptionMapper.java 
b/wicket-request/src/main/java/org/apache/wicket/request/IExceptionMapper.java
index 8dfdac4..68d9e63 100644
--- 
a/wicket-request/src/main/java/org/apache/wicket/request/IExceptionMapper.java
+++ 
b/wicket-request/src/main/java/org/apache/wicket/request/IExceptionMapper.java
@@ -19,6 +19,9 @@ package org.apache.wicket.request;
 
 /**
  * Maps exception to {@link IRequestHandler}.
+ * <p>
+ * Also see 
org.apache.wicket.request.cycle.IRequestCycleListener#onException(RequestCycle 
cycle, Exception ex)
+ * </p>
  */
 public interface IExceptionMapper
 {

Reply via email to