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))) }orafaaraujo
01/21/2020, 1:33 PMorafaaraujo
01/21/2020, 2:16 PMcatch works 😞orafaaraujo
01/21/2020, 2:17 PMval 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" } }
}orafaaraujo
01/21/2020, 2:18 PMNPE 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 😂orafaaraujo
01/21/2020, 2:52 PMthrow NullPointerException() // handled by catch
val request = searcher.searchable.searchAsync(query) { jsonObject, exception ->
throw NullPointerException() // not handled by catch
}orafaaraujo
01/21/2020, 2:55 PMcallbackFlow 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.