<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><spanclass="token keyword"></span><ahref="[common]safely.html">T</a><spanclass="token operator">></span><ahref="[common]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="index.html#-738983448%2FClasslikes%2F-1478683138">ExceptionHandler</a><spanclass="token operator"><</span><spanclass="token keyword"></span><ahref="[common]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><spanclass="token keyword"></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><spanclass="token keyword"></span><ahref="[common]safely.html">T</a></span></span><spanclass="token punctuation">)</span><spanclass="token operator">: </span><ahref="[common]safely.html">T</a></div><pclass="paragraph">It will run <ahref="[common]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="index.html#-738983448%2FClasslikes%2F-1478683138">ExceptionHandler</a>s:</p><ul><li><pclass="paragraph"><ahref="[common]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="index.html#-738983448%2FClasslikes%2F-1478683138">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="[common]safely.html">onException</a></p><h4class="">See also</h4><divdata-togglable="See also"><divclass="table"data-togglable="See also"><divclass="table-row"data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain"data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"><divclass="main-subrow keyValue WithExtraAttributes"><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><span>Handler</span></span></a></div></span></div><div></div></div></div><divclass="table-row"data-filterable-current=":micro_utils.dokka:dokkaHtml/commonMain"data-filterable-set=":micro_utils.dokka:dokkaHtml/commonMain"><divclass="main-subrow keyValue WithExtraAttributes"><divclass=""><spanclass="inline-flex"><div><ahref="[common]safely-without-exceptions.html"><span>safely</span><wbr></wbr><span>Without</span><wbr></wbr><span><span>Exceptions</span></span></a></div></span></div><div></div>