If failure is called where was no response to have a status code. When the response callback is called you must check isSuccess() (or the status code) to determine if the response was successful or not.
@JakeWharton we test it with something like wireshark and get 503 error from server but retrofit calls onFailure. So seems 5xx errors call onFailure. How can we detect this kind of status code?
Ok I found the problem! socketTimeoutException occurs after 10s and server 503 error receive after this so I can't get this code! now I want to increase time of timeout! it related to OKhttp AFAIK.
I got a response from the server but has "JsonSyntaxException" because its not the type I specify, but its a response that I need capture the code what can I do?
@JakeWharton what is the response code we get in case of success and failure api calls using retrofit
I've got the same request as @oscarshaitan.
The onFailure is called because of a JsonSyntaxException (my API returns some HTML instead of the expected JSON). But I would like to process the response body myself in this case. But as far as I can tell, there is no way to access that body from the onFailure method.
Am I missing something ?
The response was consumed by the JSON converter. It's not available.
On Tue, Mar 5, 2019, 8:03 AM Gaëtan Muller <[email protected] wrote:
I've got the same request as @oscarshaitan
https://github.com/oscarshaitan.The onFailure is called because of a JsonSyntaxException (my API returns
some HTML instead of the expected JSON). But I would like to process the
response body myself in this case. But as far as I can tell, there is no
way to access that body from the onFailure method.
Am I missing something ?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/square/retrofit/issues/1612#issuecomment-469671731,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEbsaQamu4z3XEf1Xc77zQmSTQb_6ks5vTmshgaJpZM4Hcyso
.
Thanks for the confirmation. I managed to do what I wanted by using a custom Gson converter.
Most helpful comment
If failure is called where was no response to have a status code. When the response callback is called you must check
isSuccess()(or the status code) to determine if the response was successful or not.