I am developing a spring -mvc application.
Below are the steps that I follow to handle exceptions in the code.
- Wrap an exception in a WrapperException in a catch block (along with some additional details for debugging) and return it back to the caller's method.
- Finally, handling a WrapperException in the controller.
But the problem with the above approach is that my method contains a lot of code to wrap exceptions and throw it away.
Is this acceptable behavior? or should I change my approach?
Structure My WrapperException.
public class CustomGenericException extends Exception {
private static final long serialVersionUID = 1L;
private Exception exception;
private String errCode;
private String userMsg;
private String userId;
private StringBuilder errPath;
}
Thank.
source
share