0

I Did Custom Exception handling on server side using @ControllerAdvice and extending ResponseEntityExceptionHandler . I have a requirement to call the service from rest client using rest template. Rest template uses DefaultResponseErrorHandler class for exception handling. Please provide me the sample or document to create exception handling on rest client side.

user3773610
  • 131
  • 3
  • 6
  • This link may help. http://stackoverflow.com/questions/37584379/unmarshalling-response-depending-on-http-code-during-spring-rest-service-call/37587332#37587332 – s7vr Sep 21 '16 at 09:38
  • Can I able to redirect all exceptions to server ? Because I in server ResponseEntityExceptionHandler class handles all the exceptions, If so tell me how ? If wrong thinking , please provide me good way of handling exceptions in rest template client side. – user3773610 Sep 21 '16 at 13:21
  • you need this error handler on the client side to manage server exceptions. you'll have to create a logic to check the server message from the response and act accordingly. So, on server side when exception occurs you'll have to create a json error message and add it to the response. On client side you'll deserailize the json error message and comvert them back to your exception objects. – s7vr Sep 21 '16 at 13:22
  • Client must know what the exception is through xml or json format with status code and exception message. – user3773610 Sep 21 '16 at 13:26
  • yes updated the last comment. – s7vr Sep 21 '16 at 13:27

0 Answers0