orafaaraujo
01/21/2020, 1:07 PM.catch { }
operator of Flow
should not get one NPE
that might occurs inside it?Dico
01/21/2020, 1:10 PMorafaaraujo
01/21/2020, 1:12 PM.catch { e -> emit(Result.Error(Exception(e))) }
catch
works 😞val myFlow = callbackFlow {
val json: String? = "aaa"
val something = json
?.let { mapJson("") }
?: run { listOf<Any>() }
offer(something)
}
myFlow
.catch {
logD { "myFlow catch $it" }
emit(listOf())
}
.collect { logD { "myFlow collect: $it" } }
}
NPE
when the map is wrong because of a bad JSON receivedDico
01/21/2020, 2:18 PMlouiscad
01/21/2020, 2:37 PMkotlinx.coroutines.*
and kotlinx.coroutines.flow.*
on play.kotl.inorafaaraujo
01/21/2020, 2:52 PMcatch
why? no idea 😂throw NullPointerException() // handled by catch
val request = searcher.searchable.searchAsync(query) { jsonObject, exception ->
throw NullPointerException() // not handled by catch
}
callbackFlow
instead only Flow
, to handle with something inside lambdasdave08
01/21/2020, 5:20 PMelizarov
01/22/2020, 7:23 AMsearchAsync { … }
handles exception. The root cause if there.