Android: how to return a JSON object in case of an exception using RoboSpice

I use RoboSpice to access some of the leisure services that I developed with resteasy. I return a JSON object when everything is in order, and in case of an exception, I return an http error code and a JSON object describing the nature of the exception. I can get the JSON object when everything is working fine, but I can get the exception and the http error code, but not the JSON that I just returned in case of an exception. I tried to do the same in iOS and I can get everything in every case, does anyone know how to do this with RoboSpice ?. By the way, I use Jackson and Spring. Thanks!

+6
source share
1 answer

Take a look at the method described in this thread to grab the http status for a failed request.

Note that the HttpClientErrorException has a getResponseBodyAsString() method, which should help you read the JSON response.

+6
source

Source: https://habr.com/ru/post/947908/


All Articles