📜  如何在改造中将 errorBody 转换为 pojo - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:27.195000             🧑  作者: Mango

代码示例1
if (response.isSuccessful()) {
    // Do your success stuff...

} else {
    APIError message = new Gson().fromJson(response.errorBody().charStream(), APIError.class);
    Toast.makeText(MainActivity.this, "" + message.getMessage(), Toast.LENGTH_SHORT).show();
}