LastExceed
09/04/2019, 10:59 AMrunBlocking {
try {
val listener = aSocket(ActorSelectorManager(<http://Dispatchers.IO|Dispatchers.IO>)).tcp().bind(InetSocketAddress(12345))
val socket = listener.accept()
println("client connected")
socket.openReadChannel().readInt()
}
catch (ex: Throwable) {
println("client disconnected")
}
}
when i connect to this and then disconnect it throws a `CancellationException`which is caused by an IOException
. More specifically, it is thrown in readInt()
because it's trying to read data from a closed stream. I know i can and should only catch that specific exception at that specific line, but for the example code i wrapped the entire thing in catch Throwable to make double sure it catches everything.
But even though I catch it and the catch block is executed just fine the exception is still thrown into the console. why is that?streetsofboston
09/04/2019, 11:48 AMlistener
and/or socket
are logging the exception before throwing it?LastExceed
09/04/2019, 11:49 AMstreetsofboston
09/04/2019, 1:52 PMtry
around the runBlocking
and catch
any Throwables it may throw?