blob: 95fecbf73d4eeaae1fb1291d9e60338442f47612 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
package org.pacien.tincapp.extensions
import java8.util.concurrent.CompletableFuture
/**
* @author pacien
*/
object Java {
fun <T> CompletableFuture<T>.exceptionallyAccept(fn: (Throwable) -> Unit) = exceptionally { fn(it); null }!!
fun <A, R> applyIgnoringException(f: (A) -> R, x: A, alt: R? = null) = try {
f(x)
} catch (_: Exception) {
alt
}
}
|