fun CoroutineScope.tryLaunch(
context: CoroutineContext = EmptyCoroutineContext,
start: CoroutineStart = CoroutineStart.DEFAULT,
block: suspend () -> Unit,
catch: ((e: Exception) -> Unit)? = { Timber.w(it) }) {
launch(context, start) {
try {
block()
} catch (e: Exception) {
catch?.invoke(e)
}
}
}
fun CoroutineScope.tryLaunch(
context: CoroutineContext = EmptyCoroutineContext,
start: CoroutineStart = CoroutineStart.DEFAULT,
block: suspend () -> Unit) {
tryLaunch(context = context,
start = start,
block = block,
catch = {
Timber.w(it)
})
}