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

Reply via email to