【发布时间】:2019-07-07 20:12:07
【问题描述】:
我在下面的一个通用模块中编写了一个通用代码并在JS环境中测试
val response = client.post<HttpResponse>(url) {
body = TextContent("""{"a":1,"b":2}""", ContentType.Application.Json)
}
if (response.status != HttpStatusCode.OK) {
logger.error("Error, this one failed bad?")
}
但我的代码在 client.post 结束,并在没有网络上取消了 corutineException。我该如何处理这个和任何其他异常?如果有互联网连接。没有什么失败,我希望能够处理异常。如何?
注意:try,catch 不起作用
【问题讨论】:
标签: kotlin ktor kotlin-multiplatform