You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Hannes Dohrn (JIRA)" <ji...@apache.org> on 2014/12/28 11:59:13 UTC

[jira] [Comment Edited] (WICKET-5794) Make DefaultExceptionMapper extensible

    [ https://issues.apache.org/jira/browse/WICKET-5794?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14259609#comment-14259609 ] 

Hannes Dohrn edited comment on WICKET-5794 at 12/28/14 10:58 AM:
-----------------------------------------------------------------

Not sure what you mean by "exception page". If you're talking about ExceptionErrorPage: It's already extensible (enough for my needs). I'm currently using it as basis for my customized error page. If you mean that one can override the default wicket ExceptionErrorPage: That was actually my first attempt at solving the problem. Just like you can say getApplicationSettings().setInternalErrorPage I introduced a method getApplicationSettings().setExceptionErrorPage. This method accepted a IContextProvider, where the context holds the caught exception and the current page and the get method then instantiates the exception page.

It worked but I gave up on the idea when I ran mvn verify and the clirr plugin told me that my changes break interfaces. I think added a method like setExceptionErrorPage is more in tune with how Wicket currently handles the situation. It would be enough for my purposes, even though it would feal strange to have my custom exception page send an email when instantiated. I think from an application logic perspective this should be done by the onException method (which would have to replicate the DefaultExceptionMapper functionality) or the DefaultExceptionMapper class itself.


was (Author: hannesd):
Not sure what you mean by "exception page". If you're talking about ExceptionErrorPage: It's already extensible (enough for my needs). I'm currently using it as basis for my customized error page. If you mean that one can override the default wicket ExceptionErrorPage: That was actually my first attempt at solving the problem. Just like you can say getApplicationSettings().setInternalErrorPage I introduced a method getApplicationSettings().setExceptionErrorPage. This method accepted a IContextProvider, where the context holds the caught exception and the current page and the get method then instantiates the exception page.

It worked but I gave up on the idea when I ran mvn verify and the clirr plugin told me that my changes break interfaces. My personal preference would be to make DefaultExceptionMapper customizable and use the "template method pattern" instead of 

> Make DefaultExceptionMapper extensible
> --------------------------------------
>
>                 Key: WICKET-5794
>                 URL: https://issues.apache.org/jira/browse/WICKET-5794
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 6.19.0
>            Reporter: Hannes Dohrn
>            Assignee: Andrea Del Bene
>            Priority: Minor
>         Attachments: 0001-Extracted-code-in-DefautlExceptionMapper-internalMap.patch
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
> I'd like to send an email when wicket catches an unhandled exception. Also I want to customize the ExceptionErrorPage. Wicket offers getApplicationSettings().setInternalErrorPage(...) interface to set a custom internal error page. However, unlike the ExceptionErrorPage, InternalErrorPage does not receive the caught exception object or the current page object.
> In https://github.com/hannesd/wicket/commit/a33c6dff I extracted some code from DefaultExceptionMapper#internalMap into an extra method. Also I changed private to protected methods to make DefaultExceptionMapper reusable and extensible.
> I'd be nice if this patch or something similar enters wicket 6.x so that I don't have to duplicate 99% of DefaultExceptionMapper just to get my own version of ExceptionErrorPage.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)