Description
Ktor Version
1.2.2
Ktor Engine Used(client or server and name)
Client w/ OkHTTP Engine on Android
JVM Version, Operating System and Relevant Context
IntelliJ IDEA 2019.1.3 (Ultimate Edition)
Build #IU-191.7479.19, built on May 28, 2019
JRE: 1.8.0_202-release-1483-b58 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.5
Feedback
val result: Any = httpClient.post {
url(server.baseApiUrl + "/apiPath")
body = request
contentType(ContentType.Application.Json)
}
With the above code, we found that our app doesn't throw http exceptions, which was a bit unexpected, and took a bit of debugging. result
ends up being a DelegatedResponse
, and is thus expecting us to handle the http value ourselves, which was again, unexpected.
This code was something we didn't care about the response, and so someone who didn't know what they were doing defaulted it to type Any
.
Instead of unexpectedly returning a DelegatedResponse
object, and expecting the caller to handle the error handling, it'd probably be better to throw a RuntimeException
mentioning this isn't an allowed response type, so that unexpected bugs like this don't happen.