For ktor-client SSE support, how can I handle non ...
# ktor
d
For ktor-client SSE support, how can I handle non 200 responses from the server? I'm getting a 400, but I'm not sure how to handle that in code.
a
You can catch the
SSEClientException
and observe the server response on exception. Here is an example:
Copy code
try {
    client.sse(host = "0.0.0.0", port = 8092, path = "/400") {
        incoming.collect { event ->
            println(event)
        }
    }
} catch (e: SSEClientException) {
    println(e.response?.status)
}
d
Thanks!