safely function

This commit is contained in:
InsanusMokrassar 2020-06-01 12:56:48 +06:00
parent 9ae252717d
commit 2a276d9272
2 changed files with 18 additions and 0 deletions

View File

@ -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

View File

@ -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 <T> safely(
noinline onException: ExceptionHandler<T> = { throw it },
noinline block: suspend CoroutineScope.() -> T
): T = handleSafely(
onException,
block
)