mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 00:03:48 +00:00
add plain answer to default exception
This commit is contained in:
parent
ad700f5f33
commit
f4b7bb42d6
@ -13,6 +13,7 @@
|
||||
* `UpdatesFilter` now use new type of updates for mediagroups
|
||||
* Add `GetWebhookInfo` request and `WebhookInfo` type
|
||||
* Replace updates types into separated place in types
|
||||
* Now default `RequestException` will contain plain answer from telegram
|
||||
|
||||
## 0.11.0
|
||||
|
||||
|
@ -77,7 +77,8 @@ class KtorRequestsExecutor(
|
||||
} ?: call.let {
|
||||
throw newRequestException(
|
||||
responseObject,
|
||||
"Can't get result object"
|
||||
content,
|
||||
"Can't get result object from $content"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -2,5 +2,5 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
|
||||
open class ReplyMessageNotFound(response: Response<*>, message: String?, cause: Throwable?) :
|
||||
RequestException(response, message, cause)
|
||||
open class ReplyMessageNotFound(response: Response<*>, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||
RequestException(response, plainAnswer, message, cause)
|
@ -5,15 +5,17 @@ import java.io.IOException
|
||||
|
||||
fun newRequestException(
|
||||
response: Response<*>,
|
||||
plainAnswer: String,
|
||||
message: String? = null,
|
||||
cause: Throwable? = null
|
||||
) = when (response.description) {
|
||||
"Bad Request: reply message not found" -> ReplyMessageNotFound(response, message, cause)
|
||||
else -> RequestException(response, message, cause)
|
||||
"Bad Request: reply message not found" -> ReplyMessageNotFound(response, plainAnswer, message, cause)
|
||||
else -> RequestException(response, plainAnswer, message, cause)
|
||||
}
|
||||
|
||||
open class RequestException internal constructor(
|
||||
val response: Response<*>,
|
||||
val plainAnswer: String,
|
||||
message: String? = null,
|
||||
cause: Throwable? = null
|
||||
) : IOException(
|
||||
|
Loading…
Reference in New Issue
Block a user