https://kotlinlang.org logo
#android
Title
# android
l

Loránd

05/20/2019, 9:18 AM
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

Vsevolod Kaganovych

05/20/2019, 9:27 AM
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

Loránd

05/20/2019, 9:29 AM
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

Vsevolod Kaganovych

05/20/2019, 9:31 AM
Yes, wrap it with try catch or use CoroutineExceptionHandler (which I don’t recommend). And then do whatever you want with outcome.
l

Loránd

05/20/2019, 9:34 AM
Alright, thanks alot 🙂
5 Views