Categories

Dec 20, 2019 in Service Discovery
Q: How will you deploy Exception Handling in Microservices?

1 Answer

Dec 20, 2019

If an exception occurs while processing an HTTP request, you need to catch the exception in your controller or service and return an appropriate ResponseEntity manually.  Here are some thumb rules for exception handling.

Add @ResponseStatus for exceptions that you write.

For all other exceptions, implement an @ExceptionHandler method on a @ControllerAdvice class or use an instance of SimpleMappingExceptionResolver. 

For Controller specific exceptions, add @ExceptionHandler methods to your controller. 

Point to be noted is that @ExceptionHandler methods on the controller are always selected before those on any @ControllerAdvice instance. It is undefined in what order ControllerAdvices are processed.

Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

Madanswer
Dec 20, 2019 in Service Discovery
Dec 20, 2019 in Service Discovery
May 24, 2019 in JAVA
...