1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-23 00:57:13 +00:00

add plain answer to default exception

This commit is contained in:
InsanusMokrassar 2019-03-04 10:32:26 +08:00
parent ad700f5f33
commit f4b7bb42d6
4 changed files with 9 additions and 5 deletions

View File

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

View File

@ -77,7 +77,8 @@ class KtorRequestsExecutor(
} ?: call.let {
throw newRequestException(
responseObject,
"Can't get result object"
content,
"Can't get result object from $content"
)
}
}

View File

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

View File

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