https://kotlinlang.org logo
#ktor
Title
# ktor
n

Nick

02/24/2024, 6:47 AM
i’m trying to use the new SSE functionality in 3.0’s beta. it works well in general, but i’m struggling to see a way to handle HTTP errors either at connection setup or during event consumption. the first issue feels pretty common for cases where you have an authenticated event source and access it without valid credentials. the server would want to reject the connection, usually with an Unauthorized status code. but the API for the client doesn’t really have a way to intercept this failure case. instead, the sse setup will internally throw SSEException and hide any semantics about the underlying status code. is there a recommended way to solve this? or will the API be tweaked to make this easier? i also tried
expectsSuccess
in hopes that i’d get a more concrete exception. but this didn’t work. would appreciate any help with this.
a

Aleksei Tirman [JB]

02/27/2024, 7:35 AM
Unfortunately, the current implementation doesn't allow to intercept the failure case. Can you please file an issue?
4 Views