1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2026-06-11 13:56:45 +00:00

Compare commits

..

7 Commits

Author SHA1 Message Date
renovate[bot]
2f6a6758ff Update ktor monorepo to v3.3.0 2025-09-11 13:50:35 +00:00
f22d571484 Merge pull request #1003 from InsanusMokrassar/28.0.2
28.0.2
2025-09-10 15:59:20 +06:00
9be5ebb036 refactor changelog 2025-09-10 15:58:43 +06:00
da4cd527ec fix of #1002 2025-09-10 15:45:45 +06:00
4117288b21 fix of #1001 2025-09-10 15:33:07 +06:00
458bdd3ee4 start 28.0.2 2025-09-10 15:29:55 +06:00
d469a88791 Merge pull request #1000 from InsanusMokrassar/28.0.1
28.0.1
2025-09-04 16:38:10 +06:00
6 changed files with 29 additions and 5 deletions

View File

@@ -1,5 +1,11 @@
# TelegramBotAPI changelog # TelegramBotAPI changelog
## 28.0.2
* `Core`:
* [#1001](https://github.com/InsanusMokrassar/ktgbotapi/issues/1001) - `[Bug] Invalid detection of isCausedByCancellation()`
* [#1002](https://github.com/InsanusMokrassar/ktgbotapi/issues/1002) - `Unable to handle UnauthorizedException with buildBehaviourWithLongPolling`
## 28.0.1 ## 28.0.1
* `Version`: * `Version`:

View File

@@ -9,4 +9,4 @@ kotlin.incremental.js=true
ksp.useKSP2=false ksp.useKSP2=false
library_group=dev.inmo library_group=dev.inmo
library_version=28.0.1 library_version=28.0.2

View File

@@ -8,7 +8,7 @@ javax-activation = "1.1.1"
korlibs = "5.4.0" korlibs = "5.4.0"
uuid = "0.8.4" uuid = "0.8.4"
ktor = "3.2.3" ktor = "3.3.0"
ksp = "2.2.10-2.0.2" ksp = "2.2.10-2.0.2"
kotlin-poet = "2.2.0" kotlin-poet = "2.2.0"

View File

@@ -87,6 +87,7 @@ suspend fun TelegramBot.buildBehaviourWithLongPolling(
timeoutSeconds = timeoutSeconds, timeoutSeconds = timeoutSeconds,
autoDisableWebhooks = autoDisableWebhooks, autoDisableWebhooks = autoDisableWebhooks,
autoSkipTimeoutExceptions = autoSkipTimeoutExceptions, autoSkipTimeoutExceptions = autoSkipTimeoutExceptions,
mediaGroupsDebounceTimeMillis = mediaGroupsDebounceTimeMillis mediaGroupsDebounceTimeMillis = mediaGroupsDebounceTimeMillis,
exceptionsHandler = defaultExceptionsHandler
) )
} }

View File

@@ -84,7 +84,7 @@ class DefaultKtorRequestsExecutor internal constructor(
when (e) { when (e) {
is ClientRequestException -> { is ClientRequestException -> {
val exceptionResult = runCatching { val exceptionResult = runCatchingLogging(logger = Log) {
val content = e.response.bodyAsText() val content = e.response.bodyAsText()
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content) val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
newRequestException( newRequestException(

View File

@@ -2,6 +2,17 @@ package dev.inmo.tgbotapi.utils
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
/**
* Traverses this throwable's cause chain to find a [CancellationException].
*
* It walks through `this` and its `cause`s until the first [CancellationException] is encountered,
* and returns that exception. If no [CancellationException] is found in the chain, returns `null`.
*
* This is useful when you need to distinguish cancellations from other failures while handling errors.
*
* @receiver the root [Throwable] to inspect
* @return the first [CancellationException] found in the cause chain, or `null` if none present
*/
fun Throwable.causedCancellationException(): CancellationException? { fun Throwable.causedCancellationException(): CancellationException? {
var current = this var current = this
while (current !is CancellationException) { while (current !is CancellationException) {
@@ -15,4 +26,10 @@ fun Throwable.causedCancellationException(): CancellationException? {
return current return current
} }
fun Throwable.isCausedByCancellation(): Boolean = causedCancellationException() == null /**
* Checks whether this throwable (or any of its causes) is a [CancellationException].
*
* @receiver the [Throwable] to inspect
* @return `true` if a [CancellationException] is found in the cause chain, `false` otherwise
*/
fun Throwable.isCausedByCancellation(): Boolean = causedCancellationException() != null