2020-10-04 10:57:39 +00:00
|
|
|
package dev.inmo.tgbotapi.extensions.utils
|
2020-06-01 06:56:48 +00:00
|
|
|
|
2020-11-07 07:42:10 +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
|
|
|
|
|
|
|
|
/**
|
2020-11-07 07:42:10 +00:00
|
|
|
* 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
|
|
|
*/
|
2020-11-07 07:42:10 +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
|
2020-11-07 07:42:10 +00:00
|
|
|
): T = dev.inmo.micro_utils.coroutines.safely(
|
2020-06-01 06:56:48 +00:00
|
|
|
onException,
|
|
|
|
block
|
|
|
|
)
|