Login Id [User id | Email Id] *
| New here?
Email Id *
best approach practices to handle exceptions in Spring?
Can any one brief on best practices in handling exceptions in Spring?
Some of the best practices in handling exceptions in spring:
Use Checked Exceptions if there is a reasonable expectation that the client can handle and recover from the exception otherwise use Unchecked (you will mostly use unchecked).
Use the @ExceptionHandler annotation on a method to handle exceptions generated from @RequestMapping methods.
Create custom exceptions and throw those instead (you can pass the actual exception as the cause ie throw new MyCustomException("my message", e)).
Your @ExceptionHandler method can decide what view to return to the user, or you can configure a custom error page in your web.xml
Enter Email Id