Skip to content

Commit 286c7db

Browse files
committed
fix single error handler
1 parent 30edff5 commit 286c7db

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/kotlin/com/moumoux/quinine/Quinine.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ class Quinine<K: Any, V> private constructor() {
7979
fun <K1 : K, V1 : V?> build(mappingFunction: suspend (K1) -> V1): LoadingCache<K1, V1> {
8080
return LoadingCacheDelegate(caffeine.build {
8181
Single.create<V1> { emitter ->
82-
GlobalScope.launch { emitter.onSuccess(mappingFunction(it)) }
82+
GlobalScope.launch {
83+
try {
84+
emitter.onSuccess(mappingFunction(it))
85+
} catch (e: Throwable) {
86+
emitter.onError(e)
87+
}
88+
}
8389
}.cache()
8490
})
8591
}

0 commit comments

Comments
 (0)