It is a good suggestion. In cases where we actually do want to ignore the exception, the existing approach is obviously fine, but I can definitely see the argument for using a more defensive style elsewhere.

On Aug 6, 2009, at 4:42 AM, Noel Grandin wrote:

Hi

I notice that in places Pivot has code like this:
       try {
         ... stuff....
       } catch(IllegalAccessException exception) {
       } catch(InstantiationException exception) {
       }

My preferred pattern for ignored exceptions is this:
       try {
         ... stuff....
       } catch(IllegalAccessException exception) {
throw new RuntimeException(exception); // should never happen
       } catch(InstantiationException exception) {
throw new RuntimeException(exception); // should never happen
       }

Just so that I get a stacktrace in those rare cases, where yes, somebody did something extra-ordinarily stupid and managed to trigger the exception.

Comments?

-- Noel.

Reply via email to