Ktorfit
Ktorfit copied to clipboard
Catching Fatal Errors
Hi! Is there a way, to set up an error handler, whenever a fatal error happens, the app does not stop, but it gets caught?
For example, when there is no internet connection for the app, I am getting errors like:
FATAL EXCEPTION: main
Process: com.app.app, PID: 5056
java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Net.java:107)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:663)
at io.ktor.network.sockets.SocketImpl.connect$ktor_network(SocketImpl.kt:44)
at io.ktor.network.sockets.ConnectUtilsJvmKt.connect(ConnectUtilsJvm.kt:21)
at io.ktor.network.sockets.TcpSocketBuilder.connect(TcpSocketBuilder.kt:37)
at io.ktor.client.engine.cio.ConnectionFactory.connect(ConnectionFactory.kt:30)
Hi, @Foso can you help me point to somewhere, where I can catch the Fatal Errors thrown if there is no internet on the device? What is the best practice for this?
Hi @ferenczAndras , currently your only way to detect that exception is to wrap the code, where you do the request, inside a try-catch. I started working on improving that situation https://github.com/Foso/Ktorfit/issues/389