diff --git a/CHANGELOG.md b/CHANGELOG.md index acd8b4caa8..c28c39d133 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,8 @@ * `Klock`: `1.11.1` -> `1.11.3` * `TelegramotAPI`: * Fix: for sending requests caption and text lengths limits were updated +* `TelegramBotAPI-extensions-utils`: + * `safely` function was introduced. It is in `PreviewFeature` state currently ### 0.27.4 diff --git a/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/SafelyShortcut.kt b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/SafelyShortcut.kt new file mode 100644 index 0000000000..793caa00a4 --- /dev/null +++ b/TelegramBotAPI-extensions-utils/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils/SafelyShortcut.kt @@ -0,0 +1,16 @@ +package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils + +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 safely( + noinline onException: ExceptionHandler = { throw it }, + noinline block: suspend CoroutineScope.() -> T +): T = handleSafely( + onException, + block +)