IMO, catch the database exception in user, then throw a new (wrapped) exception, catch it in UserAction and throw a new exception, and use struts decalritive exception handling features to handle it. This avoids undue coupling between UserAction, User and Database.

Gareth.

Navjot Singh wrote:

Hi,

Take a simple case.

  Action
     Y
UserAction -> User -> Database
     |
    V
 user.jsp

Say, Database throws exception. What is best way to handle exception?

1. Catch in User class and return NULL / some ErrorObject to UserAction and
let UserAction decide how to handle it?

2. Let User class __pass on__ the Exception from Database to UserAction.

2a. As execute() is already throwing Exception so it will handle ALL so Set
<global-exception> handler that can send the user to some nice page?
2b. Catch Exception in UserAction and then do some thing ...

Which one do you guys follow in not-so-large scale web applications?

would appreciate any comments.
-navjot singh




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to