Since I did not hear any response, I would like to ask folks here, humbly, one 
more time. 

Am I asking the right question? 

Or

Is my question confusing or unclear?

Here is some background info why I am asking this quesiton. I did a spring web 
app before. I have a base form controller and its onSubmit method contains an 
abstract method as follows:

public abstract ModelAndView doOnSubmit(HttpServletRequest request, 
HttpServletResponse response, Object command, BindException errors) throws 
Exception;

This base form controller's onSubmit centrally handles exceptions thrown from 
the service layer (most often the erros are database errors) and each specific 
form controller that inherits the base form controller handles business related 
to the specific form. In this way, I only need to do it once for handling 
errors and display right messages in user interface.

Hope this helps. I really would like to hear from folks here about how to do 
the right thing.

Best,
David


--- On Sun, 4/11/10, David Chang <[email protected]> wrote:

> From: David Chang <[email protected]>
> Subject: How to centrally handle common exceptions from the databsae layer?
> To: [email protected]
> Date: Sunday, April 11, 2010, 11:38 AM
> I am hoping to understand how to
> write a good wicket app regarding handling exceptions from
> the databsae layer?
> 
> For a wickt form, I can have the following to handle user
> submission: 
> 
> @Override
> protected void onSubmit() {
>   User u = getModelObject();
>   userDao.saveUser(u);
>   setResponsePage(Results.class);
> }
> 
> For a wikcet web app, I can have many forms.
> 
> But what is the best way to handle common database
> exceptions such as foreign key constraint violation, larger
> than a column width, etc. and displaying meaningful error
> messages? I could easily add try/catch around
> userDao#saveUser to handle them, but that would be bad in
> terms of code replication and maintenance. It may be good to
> handle in a "central" place.
> 
> How do you deal with this issue in your wicket apps?
> 
> Thanks for input!
> 
> Best. 
> 
> 
> 
> 
>       
> 
> ---------------------------------------------------------------------
> 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