| Article: |
An Exception Handling Framework for J2EE Applications | |
| Subject: | Bad code example | |
| Date: | 2006-01-16 23:40:21 | |
| From: | sumitaj | |
You have provided a good approach for handling exception for a J2EE app . But the code example is not good:
Like this: |
||
Showing messages 1 through 1 of 1.
-
Bad code example
2006-01-16 23:58:26 Shrik [View]
Using instanceof operator (please refer to Avoid instanceof operator (http://www.javapractices.com/Topic31.cjp) ) itself is a bad practice and you still need to use exception for program flow. In case exception needs to be dealt at any other place other than the Controller itself as mentioned in the example, it's better to make contract clear to the client instead of embedding the cause in the BaseAppException and checking its type. This kind of situation (where you need to handle the exception other than at Controller end) is rare in normal J2EE applications and for those situations I don't think there is any harm in putting the exception explicitely in the throws clause.


