Martin.
I see your point.
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.
>
Maybe make this dynamic?
ILocalRequestCycleEventErrorHandler {
boolean canHandle(String errorType);
void handleError(Expection);
}
and a place where you register them for some types "configureError",
"detachError", etc. Code will certainly get more complicated.
> > }
> > }
> > }
> > }
> >
> > 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
> >
>
--
Regards - Ernesto Reinaldo Barreiro