<divclass="content sourceset-depenent-content"data-active=""data-togglable=":micro_utils.dokka:dokkaHtml/androidMain"><divclass="symbol monospace"><spanclass="token keyword">inline suspend </span><spanclass="token keyword">fun </span><spanclass="token operator"><</span><spanclass="token keyword"></span><ahref="[android]safely.html">T</a><spanclass="token operator">></span><ahref="[android]safely.html"><spanclass="token function">safely</span></a><spanclass="token punctuation">(</span><spanclass="token keyword">noinline </span>onException<spanclass="token operator">: </span><ahref="index.html#-738983448%2FClasslikes%2F-1837788132">ExceptionHandler</a><spanclass="token operator"><</span><spanclass="token keyword"></span><ahref="[android]safely.html">T</a><spanclass="token operator">></span><spanclass="token operator"> = </span>defaultSafelyExceptionHandler<spanclass="token punctuation">, </span><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="[android]safely.html">T</a><spanclass="token punctuation">)</span><spanclass="token operator">: </span><ahref="[android]safely.html">T</a><spanclass="top-right-position"><spanclass="copy-icon"></span><divclass="copy-popup-wrapper popup-to-left"><spanclass="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><pclass="paragraph">It will run <ahref="[android]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-1837788132">ExceptionHandler</a>s:</p><ul><li><pclass="paragraph"><ahref="[android]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-1837788132">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="[android]safely.html">onException</a></p><h2class="">See also</h2><divdata-togglable="See also"><divclass="table"data-togglable="See also"><divclass="table-row"data-filterable-current=":micro_utils.dokka:dokkaHtml/androidMain"data-filterable-set=":micro_utils.dokka:dokkaHtml/androidMain"><divclass="main-subrow keyValue WithExtraAttributes"><divclass=""><spanclass="inline-flex"><ahref="default-safely-exception-handler.html">defaultSafelyExceptionHandler</a></span></div><div><divclass="title"><divdata-togglable="See also"></div></div></div></div></div><divclass="table-row"data-filterable-current=":micro_utils.dokka:dokkaHtml/androidMain"data-filterable-set=":micro_utils.dokka:dokkaHtml/androidMain"><divclass="main-subrow keyValue WithExtraAttributes"><divclass=""><spanclass="inline-flex"><ahref="[android]safely-without-exceptions.html">safelyWithoutExceptions</a></span></div><div><divclass="title"><divdata-togglable="See also"></div></div></div></div></div><divclass="table-