mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
wrap client request exception into exception handling
This commit is contained in:
parent
61ac9df5e3
commit
b873898100
@ -78,6 +78,7 @@ class KtorRequestsExecutor(
|
|||||||
pipelineStepsHolder.onRequestException(request, e) ?.let { return@let it }
|
pipelineStepsHolder.onRequestException(request, e) ?.let { return@let it }
|
||||||
|
|
||||||
if (e is ClientRequestException) {
|
if (e is ClientRequestException) {
|
||||||
|
val exceptionResult = runCatchingSafely {
|
||||||
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(
|
||||||
@ -85,6 +86,10 @@ class KtorRequestsExecutor(
|
|||||||
content,
|
content,
|
||||||
"Can't get result object from $content"
|
"Can't get result object from $content"
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
exceptionResult.exceptionOrNull() ?.let {
|
||||||
|
CommonBotException(cause = e)
|
||||||
|
} ?: exceptionResult.getOrThrow()
|
||||||
} else {
|
} else {
|
||||||
CommonBotException(cause = e)
|
CommonBotException(cause = e)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user