mplain
02/19/2022, 12:02 PMobject LoggingAsyncRunner {
    private val log: Logger = LoggerFactory.getLogger(this.javaClass)
    fun launch(job: () -> Unit) {
        CoroutineScope(Dispatchers.Default).launch {
            runHandlingErrors(job)
        }
    }
    private fun runHandlingErrors(job: () -> Unit) =
        try {
            job()
        } catch (e: IllegalArgumentException) {
            log.warn("Async job exception", e)
        } catch (e: Exception) {
            log.error("Async job exception", e)
        }
}delayjob: () -> Unitjob: suspend CoroutineScope.() -> Unitsuspendfun runHandlingErrorsobject LoggingAsyncRunner {
    private val log: Logger = LoggerFactory.getLogger(this.javaClass)
    fun launch(job: suspend CoroutineScope.() -> Unit) {
        CoroutineScope(Dispatchers.Default).launch {
            runHandlingErrors(job)
        }
    }
    private suspend fun runHandlingErrors(job: suspend CoroutineScope.() -> Unit) =
        try {
            job(~)
        } catch (e: IllegalArgumentException) {
            log.warn("Async job exception", e)
        } catch (e: Exception) {
            log.error("Async job exception", e)
        }
}no value passed for parameter p1mplain
02/19/2022, 12:03 PMmplain
02/19/2022, 12:03 PMprivate suspend fun runHandlingErrors(job: suspend CoroutineScope.() -> Unit) =
    coroutineScope {
        try {
            job()
        } catch (e: IllegalArgumentException) {
            log.warn("Async job exception", e)
        } catch (e: Exception) {
            log.error("Async job exception", e)
        }
    }mplain
02/19/2022, 12:04 PMcoroutineScope {mplain
02/19/2022, 12:04 PMmplain
02/19/2022, 12:05 PMSam
02/19/2022, 12:06 PMCoroutineScopejobjob: suspend () -> UnitSam
02/19/2022, 12:06 PMmplain
02/19/2022, 12:06 PMSam
02/19/2022, 12:07 PMCoroutineScopemplain
02/19/2022, 12:07 PMSam
02/19/2022, 12:07 PMlaunchsuspend CoroutineScope.() -> UnitSam
02/19/2022, 12:08 PMmplain
02/19/2022, 12:08 PMmplain
02/19/2022, 12:09 PMprivate fun runHandlingErrors(job: () -> Unit) =
        try {
            job()
        } catch (e: IllegalArgumentException) {
            log.warn("Async job exception", e)
        } catch (e: Exception) {
            log.error("Async job exception", e)
        }private fun runHandlingErrors(job: () -> Unit) =
        try {
            job()
        } catch (e: IllegalArgumentException) {
            log.warn("Async job exception", e)
            throw e
        } catch (e: Exception) {
            log.error("Async job exception", e)
            throw e
        }mplain
02/19/2022, 12:09 PMmplain
02/19/2022, 12:11 PMSam
02/19/2022, 12:16 PMlaunchasyncSam
02/19/2022, 12:16 PMmplain
02/19/2022, 12:16 PMmplain
02/19/2022, 12:17 PMmplain
02/19/2022, 12:18 PMSam
02/19/2022, 12:19 PMasyncDeferredDeferredSam
02/19/2022, 12:19 PMasync