https://kotlinlang.org logo
Title
n

Ngenge Senior

08/26/2019, 8:05 PM
d

Dominaezzz

08/26/2019, 8:08 PM
You don't need the
<http://Dispatchers.IO|Dispatchers.IO>
, btw.
What do you want to emit instead of null?
n

Ngenge Senior

08/26/2019, 9:53 PM
I actually want to emit a retrofit user Response (Response<User>object for example as seen.But there is definitely failure when there is no active internet connection.. I need to do that without the try catch but the app crashes when I turn off internet and works well with internet connection on
d

Dominaezzz

08/26/2019, 10:26 PM
Yes, so if there's no internet connection then where should the
Response<User>
come from?
t

trevjones

08/27/2019, 4:12 AM
The errors that can occur are a super set of what an errant Response models so you need to handle them or use a type that encapsulates the full range of possibilities. Result<Response<User>> vs try/catch perhaps
n

Ngenge Senior

08/27/2019, 2:59 PM
The exceptions are uncaught.. I have decided to handle the errors using CouroutineExceptionHandler.. I am not versed with it much but am finding my way around it
Instead of passing
<http://Dispatchers.IO|Dispatchers.IO>
, I am passing CouroutineExceptionHandler.. After doing this, the app stopped crashing but the only issue I have is notifying my fragment that there is a failure