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

17 lines
463 B
Kotlin
Raw Normal View History

package dev.inmo.tgbotapi.extensions.utils
2020-06-01 06:56:48 +00:00
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
import kotlinx.coroutines.CoroutineScope
/**
* Shortcut for [handleSafely]. It was created for more comfortable way of handling different things
*/
@PreviewFeature
suspend inline fun <T> safely(
noinline onException: ExceptionHandler<T> = { throw it },
noinline block: suspend CoroutineScope.() -> T
): T = handleSafely(
onException,
block
)