How to read error body sent by server when using Retrofit + Coroutine

When using Coroutine with Retrofit in order to call network apis, in case the server returns an error (response code != 200) we will get an Exception. My question is how to find/read the error body (in Json) sent by the server through the Exception?

     //How to read error body from exception

Read more here:

Content Attribution

This content was originally published by Ehsan Heidari at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: