📜  api调用时如何处理错误-任何代码示例

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

代码示例1
val gson = Gson()
val type = object : TypeToken() {}.type
var errorResponse: ErrorResponse? = gson.fromJson(response.errorBody()!!.charStream(), type)