Using Javascript in a browser, when `HttpClient.we...
# ktor
n
Using Javascript in a browser, when
HttpClient.webSocketSession()
fails with HTTP 401 error then a generic
WebSocketException
is throw:
Copy code
WebSocketException: {"target":{},"type":"error","isTrusted":true}
The same exception is thrown when connection fails because the server is not running. Is it possible to somehow differentiate among the various errors that can happen when connecting? Thanks.
a
I get the
NoTransformationFoundException
when the server replies with 401 status code:
Copy code
val client = HttpClient(Js) {
    install(WebSockets)
}
try {
    client.webSocketSession("<https://httpbin.org/status/401>")
} catch (e: Throwable) {
    e.printStackTrace()
}
👀 1
🙏 1