micro_utils.dokka
0.15.1

# safely

inline suspend fun <T> safely(noinline onException: ExceptionHandler<T> = defaultSafelyExceptionHandler, noinline block: suspend CoroutineScope.() -> T): T

It will run block inside of supervisorScope to avoid problems with catching of exceptions

Priorities of ExceptionHandlers:

- onException In case if custom (will be used anyway if not defaultSafelyExceptionHandler)

- CoroutineContext.get with SafelyExceptionHandlerKey as key

- defaultSafelyExceptionHandler

Remember, that ExceptionHandler from CoroutineContext.get will be used anyway if it is available. After it will be called onException

#### See also

defaultSafelyExceptionHandler
safelyWithoutExceptions
safelyWithContextExceptionHandler

#### Parameters

onException

Will be called when happen exception inside of block. By default will throw exception - this exception will be available for catching