launchCatching

fun CoroutineScope.launchCatching(catch: (Throwable) -> Unit? = null, block: suspend CoroutineScope.() -> Unit): Job

Extension function for CoroutineScope that launches a coroutine with error handling. This function provides a convenient way to launch coroutines with custom error handling logic.

Return

Job representing the launched coroutine

Parameters

catch

Optional callback function that will be invoked when an exception occurs

block

The coroutine code block to execute