Repository: wicket
Updated Branches:
  refs/heads/master 8538df05c -> c819c6c4c


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/c819c6c4
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/c819c6c4
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/c819c6c4

Branch: refs/heads/master
Commit: c819c6c4cda01f805e078e2d32482cd234cb53a5
Parents: 8538df0
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 21:59:23 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/c819c6c4/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 5b232d8..95c05af 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Application.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Application.java
@@ -677,7 +677,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 Supplier<IExceptionMapper> getExceptionMapperProvider()
        {

http://git-wip-us.apache.org/repos/asf/wicket/blob/c819c6c4/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/c819c6c4/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/c819c6c4/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 709699b..3eb63c0 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>
  */
 @FunctionalInterface
 public interface IExceptionMapper

Reply via email to