Hello why my flow is not catched when an exception...
# coroutines
p
Hello why my flow is not catched when an exception is thrown? my flow is
Copy code
flow {
val resultService = service.getWhatever()
val mapStuff = resultService.mapper() <-- it throws NullPointer
emit(mapStuff)
}
Then on my viewmodel I have
Copy code
usecase.execute(2)
.catch{do something}
.collect{expectedStuff}
What I'm missing? Do I have to add a 
.catch
  on my datasource so the viewmodel is aware something crashed?
g
what is not catched?
r
I believe they are asking why "why is the exception not caught (in
catch { do something }
)"
g
exception will be caught by catch not sure what kind behaviour is expected, try reproduce you issue on https://play.kotlinlang.org/ this sample doesn’t look complete
p
resultService.mapper() is throwing a NPE and I thought doing the catch in the viewModel would get that crash but it closes the app
g
Could.you show a some complete reproducible example, I believe there is some another problem, catch works for this case