<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="run-catching-safely.html">T</a><spanclass="token operator">></span><ahref="run-catching-safely.html"><spanclass="token function">runCatchingSafely</span></a><spanclass="token punctuation">(</span><spanclass="parameters "><spanclass="parameter ">onException<spanclass="token operator">: </span><ahref="-exception-handler/index.html">ExceptionHandler</a><spanclass="token operator"><</span><ahref="run-catching-safely.html">T</a><spanclass="token operator">></span><spanclass="token punctuation">, </span></span><spanclass="parameter ">block<spanclass="token operator">: </span><spanclass="token keyword">suspend </span><spanclass="token punctuation">(</span><spanclass="token punctuation">)</span><spanclass="token operator"> -></span><ahref="run-catching-safely.html">T</a></span></span><spanclass="token punctuation">)</span><spanclass="token operator">: </span><ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html">Result</a><spanclass="token operator"><</span><ahref="run-catching-safely.html">T</a><spanclass="token operator">></span><spanclass="clearfix"><spanclass="floating-right">(<ahref="https://github.com/InsanusMokrassar/MicroUtils/blob/master//coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/HandleSafely.kt#L18">source</a>)</span></span></div><pclass="paragraph">Launching <ahref="run-catching-safely.html">block</a> in <ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/index.html">runCatching</a>. In case of failure, it will:</p><ul><li><pclass="paragraph">Try to get <ahref="-context-safely-exception-handler/index.html">ContextSafelyExceptionHandler</a> from current <ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/index.html">coroutineContext</a> and call its <ahref="-context-safely-exception-handler/handler.html">ContextSafelyExceptionHandler.handler</a> invoke. <strong>Thrown exception from its handler will pass out of </strong><ahref="run-catching-safely.html"><strong>runCatchingSafely</strong></a></p></li><li><pclass="paragraph">Execute <ahref="run-catching-safely.html">onException</a> inside of new <ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/index.html">runCatching</a> and return its result. Throws exception will be caught by <ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/index.html">runCatching</a> and wrapped in <ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html">Result</a></p></li></ul><spanclass="kdoc-tag"><h4class="">Return</h4><pclass="paragraph"><ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html">Result</a> with result of <ahref="run-catching-safely.html">block</a> if no exceptions or <ahref="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html">Result</a> from <ahref="run-catching-safely.html">onException</a> execution</p></span><hr><divclass="symbol monospace"><spanclass="token keyword">inline suspend </span><spanclass="token keyword">fun </span><spanclass="token operator"><</span><ahref="run-catching-safely.html">T</a><spanclass="token punctuation">, </span><ahref="run-catching-safely.html">R</a><spanclass="token operator">></span><ahref="run-catching-safely.html">R</a><spanclass="token punctuation">.</span><ahref="run-catching-safely.html"><spanclass="token function">runCatchingSafely</span></a><spanclass="token punctuation">(</span><spanclass="parameters "><spanclass="parameter ">onException<spanclass="token operator">: </span><ahref="-exception-handler/index.html">ExceptionHandler</a><spanclass="token operator"><</span><ahref="run-catching-safely.html">T</a><spanclass="tokenoperat