I am using spring RestTemplate
to consume rest services(exposed in spring rest). I am able to consume success scenarios. But for negative scenarios, service returns
I found solution. HttpClientErrorException
worked for me.
It has e.getResponseBodyAsString()
function which returns ResponseBody.
You might want to distinguish between:
HttpClientErrorException
(HTTP-Status >=400) or HttpServerErrorException
(HTTP-Status >= 500) or even RestClientException
.
Further on there is a good doc about defining your own ErrorHandler, see this link