how to convert errorbody to pojo in retrofit

Solutions on MaxInterview for how to convert errorbody to pojo in retrofit by the best coders in the world

showing results for - "how to convert errorbody to pojo in retrofit"
Linus
05 Apr 2019
1if (response.isSuccessful()) {
2    // Do your success stuff...
3
4} else {
5    APIError message = new Gson().fromJson(response.errorBody().charStream(), APIError.class);
6    Toast.makeText(MainActivity.this, "" + message.getMessage(), Toast.LENGTH_SHORT).show();
7}
8