• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design issue- should ActionServlet catch all exceptions

 
Walker Rustin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code:
try{
userController.createUser(userDetails);
}catch(CreateException ex){
s.setAttribute("user.failure.create","something");
return mapping.findForward("failure");
}
I am trying to insert an entity and userController is a session bean to which a value object( a standard java bean) is being passed. The createUser method of session bean throws just one CreateException.
My question is: Should I handle just CreateException in the servlet. Obviously the container could throw EJBEXception (or any of the run time exceptions too). Or should all clietn handle catch(Exception e) {}.
thanks.
- walk rustin
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Walker Rustin:
My question is: Should I handle just CreateException in the servlet. Obviously the container could throw EJBEXception (or any of the run time exceptions too). Or should all clietn handle catch(Exception e) {}.

IMO,
Remote EJB Client - CreateException, RemoteException
Local EJB Client - CreateException, EJBException.(Runtime exception)
Trying to catch all exceptions at different places may not be a good idea. You could allow other run time exceptions to percolate to the JSP/Struts layer and catch it one place and redirect the user to an custom-error page.
If you try posting this in the EJB forum, you are likely to get more answers.....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic