I have a websocket ``` webSocket("/chat/{user_i...
# ktor
a
I have a websocket
Copy code
webSocket("/chat/{user_id}") {
        val userId = "call.getUserId()"
        webSocketConnectionManager.addSession(userId, this)

        try {
            for (frame in incoming) {
                if(frame is Frame.Text){
                    val message =  gson.fromJson(frame.readText(), MessageDto::class.java)
                    val response = chatService.sendMessage(userId, message.roomId, message.content)
                }
            }
        } finally {
            webSocketConnectionManager.removeSession(userId)
        }
    }
Lets assume that gson throw a exception, cause client send data in invalid structure. How to return some nice response, without using try catch, is it possible to do it somehow with status pages? Pipelines?
a
If the
chatService.sendMessage
function operates by sending WebSocket frames, then, unfortunately, it cannot utilize pipeline mechanisms similar to those available for HTTP in Ktor, as WebSocket communications do not support such features.