1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-12-14 18:25:44 +00:00
This commit is contained in:
2020-05-14 13:11:46 +06:00
parent b5632626ad
commit b40cc0c1ea
7 changed files with 18 additions and 15 deletions

View File

@@ -3,6 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.supervisorScope
typealias ExceptionHandler<T> = suspend (Exception) -> T
/**
* It will run [block] inside of [supervisorScope] to avoid problems with catching of exceptions
*
@@ -10,7 +12,7 @@ import kotlinx.coroutines.supervisorScope
* exception will be available for catching
*/
suspend inline fun <T> handleSafely(
noinline onException: suspend (Exception) -> T = { throw it },
noinline onException: ExceptionHandler<T> = { throw it },
noinline block: suspend CoroutineScope.() -> T
): T {
return try {