Screenshot from 2019-08-26 20-56-16.png
# android
n
Screenshot from 2019-08-26 20-56-16.png
d
You don't need the
<http://Dispatchers.IO|Dispatchers.IO>
, btw.
What do you want to emit instead of null?
n
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
Yes, so if there's no internet connection then where should the
Response<User>
come from?
t
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
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