【发布时间】:2021-08-14 08:52:24
【问题描述】:
我想使用 Retrofit 阅读错误消息。我已经尝试过 errorbody.message() 和 errorBody().string。
错误信息邮递员截图
当使用 errorBody().string() 时能够打印错误消息,但是当附加到 Toast 时,它返回空消息。 谁能帮忙解决这个问题?
println("errr,,,,,,," + response.errorBody()!!.string()) // output Middle name mst provide
println("errr,,,,,,," + response.errorBody()!!.toString()) //Response{protocol=h2, code=400, message=, url="myurl"}
Toast.makeText(context,response.errorBody()!!.string(),Toast.LENGTH_SHORT).show()
【问题讨论】:
标签: android rest retrofit retrofit2