Hi,
This is a very general question, I hope you won't laugh or scold me.Anyway here it comes:
I am using struts2, hibernate, jpa and spring.I have four layers in my application:
1.Struts Action Layer,
2.Business Layer,
3.Service Layer,
4.Common Utility Layer
So I need to define a Custom Exceptions so that if exception happens at server layer which is database layer it will go to the business layer and then business layer will throw a new exception and this exception with go to the Struts Action layer.From there I will throw the MainApplicationException and then I will show to the end user some meaningful information instead of null pointer exception.
I have defined a custom exception shown below:
public class MainApplicationException extends Exception{
private static final long serialVersionUID = 1L;
/**
* @param ErrMsg: error message.
*/
public MainApplicationException(String ErrMsg) {
super(ErrMsg);
}
}
The MainApplicationException is the root exception.After that all the above mentioned exception happens.
Please suggest me how should I proceed. If possible put some some code.
Thanks in advance.