Spring Boot Exception Handling
Custom Exception Class
These classes enable us to customize an exception according to the callers’ needs.
ApiRequestException: Is thrown when tries to add an already existing admin email or nic.
Global Exception Handling Using @ControllerAdvice
A controller advice enables you to apply the same exception handling procedures across the entire program, rather than simply to a single controller. They can be
compared to an annotation-driven interceptor.
1. First we have to create a payload containing exception details.
2. Then return the response entity.
The class that will represent the actual exception
message : the error message associated with the exception
httpStatus : the HTTP status code
timestamp : store the instant on the timeline up to a precision of nanoseconds



0 Comments