【发布时间】:2021-07-11 16:51:02
【问题描述】:
我有改造服务:
suspend fun getArticles(): Articles
如果出现错误,通常我可以在try/catch 中获得响应代码。
try {
val articles = service.getArticles()
} catch (e: Exception) {
// I can get only codes different from 200...
}
但是,如果我需要区分 200 和 202 代码,而我的服务只返回数据对象,该怎么办?
响应成功后如何获取响应码?
【问题讨论】:
标签: android retrofit retrofit2 kotlin-coroutines