have you tried it and does it work?

-igor


On Feb 15, 2008 1:17 PM, Cristiano Kliemann <[EMAIL PROTECTED]> wrote:
>
> Hi!
>
> I have some business runtime exceptions that I want to be automatically
> catched and its message rendered in the same page that threw it instead of
> redirecting to an error page.
>
> Is there a safe way to do that?
>
> These 'business exceptions' are usually thrown in some specific methods like
> onSubmit and onClick. Extending the specific components is not an option for
> me.
>
> I did something I think it dangerous. Something like:
>
> public Page onRuntimeException(Page page, RuntimeException e) {
>
>     Throwable current = e;
>     while (current != null && !(current instanceof MyBusinessException)) {
>         current = current.getCause();
>     }
>     if (current != null) {
>         // MyBusinessException detected
>         page.error("Error: " + current.getMessage());
>         return page;
>     } else {
>         return super.onRuntimeException(page, e);
>     }
> }
>
> When as exception is thrown, all the execution flow breaks, making some
> things not happen. The question is: is the above code safe assuming that
> MyException could be thrown only by methods like onSubmit and onClick?
> --
> View this message in context: 
> http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15510198.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to