Exception handling is vital aspect of any application or service. Exceptions should be handled properly and appropriate messages must be generated to end user or service in case of any exception. Same applies to REST services also whether they are used by some front-end application or some other service uses it to perform some operations. It becomes tricky when we deal with REST services as we need to expose all the supported status codes for both success and error response which our service can generate, so client application or service can handle them appropriately. Below are some samples of the status code. 200 - OK (API processes the request perfectly) 404 - Not found (Request URI or resource is not available) 500 - Internal server error (Request failed due to some error at runtime at service side) There are multiple ways to handle the exceptions which we will see in below sections. Manual exception handling We can handle the exception manually also like usin...
Blogs about Java, J2ee, Multithreading, Data structure, Algorithm, Spring framework, Spring boot, Web services and open source technologies