<divclass="platform-hinted "data-platform-hinted="data-platform-hinted"><divclass="content sourceset-dependent-content"data-active=""data-togglable=":micro_utils.dokka:dokkaHtml/commonMain"><divclass="symbol monospace"><spanclass="token keyword">inline suspend </span><spanclass="token keyword">fun </span><spanclass="token operator"><</span><ahref="safely.html">T</a><spanclass="token operator">></span><ahref="safely.html"><spanclass="token function">safely</span></a><spanclass="token punctuation">(</span><spanclass="parameters "><spanclass="parameter "><spanclass="token keyword">noinline </span>onException<spanclass="token operator">: </span><ahref="-exception-handler/index.html">ExceptionHandler</a><spanclass="token operator"><</span><ahref="safely.html">T</a><spanclass="token operator">></span><spanclass="token operator"> = </span>defaultSafelyExceptionHandler<spanclass="token punctuation">, </span></span><spanclass="parameter "><spanclass="token keyword">noinline </span>block<spanclass="token operator">: </span><spanclass="token keyword">suspend </span><spandata-unresolved-link="kotlinx.coroutines/CoroutineScope///PointingToDeclaration/">CoroutineScope</span><spanclass="token punctuation">.</span><spanclass="token punctuation">(</span><spanclass="token punctuation">)</span><spanclass="token operator"> -></span><ahref="safely.html">T</a></span></span><spanclass="token punctuation">)</span><spanclass="token operator">: </span><ahref="safely.html">T</a><spanclass="clearfix"><spanclass="floating-right">(<ahref="https://github.com/InsanusMokrassar/MicroUtils/blob/master//coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/HandleSafely.kt#L99">source</a>)</span></span></div><pclass="paragraph">It will run <ahref="safely.html">block</a> inside of <spandata-unresolved-link="kotlinx.coroutines//supervisorScope/#kotlin.coroutines.SuspendFunction1[kotlinx.coroutines.CoroutineScope,TypeParam(bounds=[kotlin.Any?])]/PointingToDeclaration/">supervisorScope</span> to avoid problems with catching of exceptions</p><pclass="paragraph">Priorities of <ahref="-exception-handler/index.html">ExceptionHandler</a>s:</p><ul><li><pclass="paragraph"><ahref="safely.html">onException</a> In case if custom (will be used anyway if not <ahref="default-safely-exception-handler.html">defaultSafelyExceptionHandler</a>)</p></li><li><pclass="paragraph"><ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/-coroutine-context/get.html">CoroutineContext.get</a> with SafelyExceptionHandlerKey as key</p></li><li><pclass="paragraph"><ahref="default-safely-exception-handler.html">defaultSafelyExceptionHandler</a></p></li></ul><pclass="paragraph">Remember, that <ahref="-exception-handler/index.html">ExceptionHandler</a> from <ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/-coroutine-context/get.html">CoroutineContext.get</a> will be used anyway if it is available. After it will be called <ahref="safely.html">onException</a></p><h4class="">Parameters</h4><divclass="table"><divclass="table-row"data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain"data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"><divclass="main-subrow keyValue "><divclass=""><spanclass="inline-flex"><div><u><span>on</span><wbr></wbr><span><span>Exception</span></span></u></div></span></div><div><divclass="title"><pclass="paragraph">Will be called when happen exception inside of <ahref="safely.html">block</a>. By default will throw exception - this exception will be available for catching</p></div></div></div></div></div><h4class="">See also</h4><divclass="table"><divclass="table-row"data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain"data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"><divclass="main-subrow keyValue "><divclass=""><spanclass="inline-flex"><div><ahref="default-safely-exception-handler.html"><span>default</span><wbr></wbr><span>Safely</span><wbr></wbr><span>Exception</span><wbr></wbr><span><spa