You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Ludwig <ge...@gmail.com> on 2012/04/03 23:34:11 UTC

Tapestry 5.3.2 throws TapestryException even though the original Exception was caught and properly handled

Hi all,

In my page there is a method that calculates a number, which might throw a
divide by zero or null pointer Exception. This number is used in other
methods that do some calculation and return a useful String to be displayed
by the UI.

The problem is that when an Exception is thrown during the calculation of
the number, Tapestry detects that an Exception was thrown even though it
was gracefully handled, and throws a TapestryException. This completely
de-rails my own Exception handling.

Is this considered correct behavior? Is there a graceful workaround to this?

Most trivial example:

MyPage.java:
////
public String getMyNumber() {
   try {
      int number=calcMyNumber();
      return String.parseInt(number);
   } catch(Exception e) {
      return "number not available";
   }
}

private int calcMyNumber() throws Exception {
  int theNumber=  ... // calculations that may throw a divide by zero or NPE
  return theNumber;
}
////

MyPage.tml:
////
Here is the number: ${myNumber}
////

When Tapestry tries to render the page, even though any Exception thrown by
calcMyNumber() is properly caught by getMyNumber() and a proper String
value is returned, Tapestry still throws a TapestryException after
getMyNumber() returns the String "number not available".

This behavior makes it impossible for me to handle Exceptions!

Best,

George

Re: Tapestry 5.3.2 throws TapestryException even though the original Exception was caught and properly handled

Posted by George Ludwig <ge...@gmail.com>.
Thiago,

Thanks for the rapid reply. While putting together a test case to send you
(the actual code is very long and complex), I figured out this was an error
on my part.

Basically, I assumed the exception was being thrown by one method, when in
fact it was being thrown by a different method

Obviously I need to take a break!

Best,

George

On Tue, Apr 3, 2012 at 2:38 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Tue, 03 Apr 2012 18:34:11 -0300, George Ludwig <ge...@gmail.com>
> wrote:
>
>  Hi all,
>>
>
> Hi!
>
>
>  The problem is that when an Exception is thrown during the calculation of
>> the number, Tapestry detects that an Exception was thrown even though it
>> was gracefully handled, and throws a TapestryException. This completely
>> de-rails my own Exception handling.
>>
>> Is this considered correct behavior?
>>
>
> No. Full page code and stack trace please.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>

Re: Tapestry 5.3.2 throws TapestryException even though the original Exception was caught and properly handled

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 03 Apr 2012 18:34:11 -0300, George Ludwig <ge...@gmail.com>  
wrote:

> Hi all,

Hi!

> The problem is that when an Exception is thrown during the calculation of
> the number, Tapestry detects that an Exception was thrown even though it
> was gracefully handled, and throws a TapestryException. This completely
> de-rails my own Exception handling.
>
> Is this considered correct behavior?

No. Full page code and stack trace please.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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