1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-03 00:15:27 +00:00
tgbotapi/tgbotapi.extensions.utils/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils/SafelyShortcut.kt

18 lines
660 B
Kotlin
Raw Normal View History

package dev.inmo.tgbotapi.extensions.utils
2020-06-01 06:56:48 +00:00
import dev.inmo.micro_utils.coroutines.ExceptionHandler
2020-10-04 11:06:30 +00:00
import dev.inmo.tgbotapi.utils.*
2020-06-01 06:56:48 +00:00
import kotlinx.coroutines.CoroutineScope
/**
* Shortcut for [dev.inmo.micro_utils.coroutines.safely]. It was created for more comfortable way of handling different things
2020-06-01 06:56:48 +00:00
*/
@Deprecated("In future will be used typealias from micro_utils", ReplaceWith("safely", "dev.inmo.micro_utils.coroutines.safely"))
2020-06-01 06:56:48 +00:00
suspend inline fun <T> safely(
noinline onException: ExceptionHandler<T> = { throw it },
noinline block: suspend CoroutineScope.() -> T
): T = dev.inmo.micro_utils.coroutines.safely(
2020-06-01 06:56:48 +00:00
onException,
block
)