You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by captain_rhino <gr...@axa-travel-insurance.com> on 2012/07/19 14:53:39 UTC

Intercepting exceptions/errors in logic within page objects

I have several pages that several methods within them

public class Page
  public void onActivate(EventContext ec){
    //Code
  }

  public void onSuccess(){
    //code
  }

  void onSelectedFromAButton(){
     //code
  }

In tapestry if any of the code goes wrong within my methods, in Tapestry
what is the best way to intercept any thing that goes wrong and then
redirect the user to for example an error page.

I do not want to put a try catch in each method and then redirect to my
error page.


Thx in advance.



}

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Intercepting-exceptions-errors-in-logic-within-page-objects-tp5714597.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Intercepting exceptions/errors in logic within page objects

Posted by Kalle Korhonen <ka...@gmail.com>.
On Thu, Jul 19, 2012 at 7:49 AM, Lenny Primak <lp...@hope.nyc.ny.us> wrote:
> Tynamo has a wonderful module called tapestry-exception page.
> It's created just for this purpose. Tynamo.org.

And in Tapestry 5.4, tapestry-exceptionpage is built-in. If the
handling is specific to a particular page, I'd use onException. If the
handling is the same for all exceptions of certain type regardless of
the page, then tapestry-exceptionpage.

Kalle


> On Jul 19, 2012, at 8:53 AM, captain_rhino <gr...@axa-travel-insurance.com> wrote:
>
>> I have several pages that several methods within them
>>
>> public class Page
>>  public void onActivate(EventContext ec){
>>    //Code
>>  }
>>
>>  public void onSuccess(){
>>    //code
>>  }
>>
>>  void onSelectedFromAButton(){
>>     //code
>>  }
>>
>> In tapestry if any of the code goes wrong within my methods, in Tapestry
>> what is the best way to intercept any thing that goes wrong and then
>> redirect the user to for example an error page.
>>
>> I do not want to put a try catch in each method and then redirect to my
>> error page.
>>
>>
>> Thx in advance.
>>
>>
>>
>> }
>>
>> --
>> View this message in context: http://tapestry.1045711.n5.nabble.com/Intercepting-exceptions-errors-in-logic-within-page-objects-tp5714597.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Intercepting exceptions/errors in logic within page objects

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
Tynamo has a wonderful module called tapestry-exception page. 
It's created just for this purpose. Tynamo.org.  



On Jul 19, 2012, at 8:53 AM, captain_rhino <gr...@axa-travel-insurance.com> wrote:

> I have several pages that several methods within them
> 
> public class Page
>  public void onActivate(EventContext ec){
>    //Code
>  }
> 
>  public void onSuccess(){
>    //code
>  }
> 
>  void onSelectedFromAButton(){
>     //code
>  }
> 
> In tapestry if any of the code goes wrong within my methods, in Tapestry
> what is the best way to intercept any thing that goes wrong and then
> redirect the user to for example an error page.
> 
> I do not want to put a try catch in each method and then redirect to my
> error page.
> 
> 
> Thx in advance.
> 
> 
> 
> }
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Intercepting-exceptions-errors-in-logic-within-page-objects-tp5714597.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Intercepting exceptions/errors in logic within page objects

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 19 Jul 2012 09:53:39 -0300, captain_rhino  
<gr...@axa-travel-insurance.com> wrote:

> I have several pages that several methods within them
>
> public class Page
>   public void onActivate(EventContext ec){
>     //Code
>   }
>
>   public void onSuccess(){
>     //code
>   }
>
>   void onSelectedFromAButton(){
>      //code
>   }
>
> In tapestry if any of the code goes wrong within my methods, in Tapestry
> what is the best way to intercept any thing that goes wrong and then
> redirect the user to for example an error page.
>
> I do not want to put a try catch in each method and then redirect to my
> error page.

AnyReturnTypeYouWant onException(Throwable throwable) {
	...
}

Check http://tapestry.apache.org/component-events.html, section  
Intercepting Event Exception.

What Lance suggested is the way to go for application-wide exceptions,  
while the method above is good for exception handling that is specific to  
one given page.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Intercepting exceptions/errors in logic within page objects

Posted by Lance Java <la...@googlemail.com>.
Tapestry's default behaviour is to redirect to the ExceptionReport page. If
you want to use your own custom page, you can override the
SymbolConstants.EXCEPTION_REPORT_PAGE symbol. Make sure that your custom
page implements ExceptionReporter.

If you'd like to override this behaviour all together, then you will need to
override the RequestExceptionHandler service with your own implementation
(take a look at the DefaultRequestExceptionHandler source code for
inspiration).

Cheers,
Lance.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Intercepting-exceptions-errors-in-logic-within-page-objects-tp5714597p5714598.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org