On Mon, Dec 15, 2014 at 11:59 AM, Ernesto Reinaldo Barreiro <
[email protected]> wrote:
>
> Maybe just add, if it does not exists, a global hook users can implement to
> do a different strategy to handle detach errors? So, that noise will be on
> users side if they want so. E.g. On AbstractAjaxResponse
>
>
> public void detach(IRequestCycle requestCycle)
> {
> Iterator<Component> iterator = markupIdToComponent.values().iterator();
> while (iterator.hasNext())
> {
> final Component component = iterator.next();
> final Page parentPage = component.findParent(Page.class);
> if (parentPage != null)
> {
> parentPage.detach();
> break;
> }
> }
> }
>
> replace with
>
> public void detach(IRequestCycle requestCycle)
> {
> Iterator<Component> iterator = markupIdToComponent.values().iterator();
> while (iterator.hasNext())
> {
> final Component component = iterator.next();
> final Page parentPage = component.findParent(Page.class);
> if (parentPage != null)
> {
>                                 try {
> parentPage.detach();
> break;
>                                 } catch(Exception e) {
>
> getApplicationSettring().getSomeHook().handleDetachError(e);
>

We have this
already: org.apache.wicket.request.cycle.IRequestCycleListener#onException()

The ticket asks for more data about the failing the component.
One'd say #handleDetachError(e, this) should do it.
But then another user will ask for handleConfigureError(e, this), yet
another handleBeforeRenderError(e, this), etc. And it will become really
ugly.


>                                 }
> }
> }
> }
>
> default will just re-throw exception
>
> On Mon, Dec 15, 2014 at 9:05 AM, Martin Grigorov <[email protected]>
> wrote:
> >
> > Yes, it can be.
> > It can be anywhere as long as the exception message provides the required
> > information (component type, path in page, some info about its model,
> > etc.).
> >
> > IMO adding such kind of code to any of the methods in the API will lead
> to
> > further tickets about adding similar code to other methods too.
> >
> > The code snippet looks like a noise to me. But others find it useful. So
> I
> > ask for more opinions whether we want to go this road.
> >
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> > https://twitter.com/mtgrigorov
> >
> > On Mon, Dec 15, 2014 at 10:57 AM, Ernesto Reinaldo Barreiro <
> > [email protected]> wrote:
> > >
> > > Can't this wrapping be done on the code that calls detach?
> > >
> > > On Mon, Dec 15, 2014 at 8:41 AM, Martin Grigorov <[email protected]
> >
> > > wrote:
> > > >
> > > > Hi,
> > > >
> > > > https://issues.apache.org/jira/browse/WICKET-5776 suggests to
> > try/catch
> > > > and
> > > > wrap exceptions in Component#detach() so that it is easier for the
> > > > application developer to identify the problematic component.
> > > > The reporter suggests code like:
> > > >
> > > > void detach() {
> > > >   try {
> > > >     // detachChildren  } catch (ComponentDetachException cde) {
> > > >     throw cde;
> > > >   } catch (Exception e) {
> > > >     throw new ComponentDetachException("Error detaching component " +
> > > > getPath() +
> > > >       (getDefaultModel() != null ? " with a " +
> > > > getDefaultModel().getClass().getName() + " model" : "") + ": " + e,
> > > > e);
> > > >   }
> > > > }
> > > >
> > > >
> > > > In a comment in the ticket I explain my concerns.
> > > >
> > > > What do you think about this suggestion ?
> > > >
> > > > Martin Grigorov
> > > > Wicket Training and Consulting
> > > > https://twitter.com/mtgrigorov
> > > >
> > >
> > >
> > > --
> > > Regards - Ernesto Reinaldo Barreiro
> > >
> >
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
>

Reply via email to