I have begun using coroutines together with retrof...
# android
l
I have begun using coroutines together with retrofit and added the call adapter to my retrofit builder. However whenever i put the device into flight mode and try to make a request it crashes the app with an exception that seems to be internal.
Fatal Exception: java.net.UnknownHostException
and
Fatal Exception: java.net.SocketTimeoutException
anyone that has had a similar issue before?
v
You have to catch this exception otherwise your app will crash. This crash is caused by http client. It cannot connect with your server due to lack of internet connection.
l
I see, so basically a try catch when awaiting the response then return an error if an exception is thrown if i understood it right
v
Yes, wrap it with try catch or use CoroutineExceptionHandler (which I don’t recommend). And then do whatever you want with outcome.
l
Alright, thanks alot 🙂