mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +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
|
* `UpdatesFilter` now use new type of updates for mediagroups
|
||||||
* Add `GetWebhookInfo` request and `WebhookInfo` type
|
* Add `GetWebhookInfo` request and `WebhookInfo` type
|
||||||
* Replace updates types into separated place in types
|
* Replace updates types into separated place in types
|
||||||
|
* Now default `RequestException` will contain plain answer from telegram
|
||||||
|
|
||||||
## 0.11.0
|
## 0.11.0
|
||||||
|
|
||||||
|
@ -77,7 +77,8 @@ class KtorRequestsExecutor(
|
|||||||
} ?: call.let {
|
} ?: call.let {
|
||||||
throw newRequestException(
|
throw newRequestException(
|
||||||
responseObject,
|
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
|
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||||
|
|
||||||
open class ReplyMessageNotFound(response: Response<*>, message: String?, cause: Throwable?) :
|
open class ReplyMessageNotFound(response: Response<*>, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||||
RequestException(response, message, cause)
|
RequestException(response, plainAnswer, message, cause)
|
@ -5,15 +5,17 @@ import java.io.IOException
|
|||||||
|
|
||||||
fun newRequestException(
|
fun newRequestException(
|
||||||
response: Response<*>,
|
response: Response<*>,
|
||||||
|
plainAnswer: String,
|
||||||
message: String? = null,
|
message: String? = null,
|
||||||
cause: Throwable? = null
|
cause: Throwable? = null
|
||||||
) = when (response.description) {
|
) = when (response.description) {
|
||||||
"Bad Request: reply message not found" -> ReplyMessageNotFound(response, message, cause)
|
"Bad Request: reply message not found" -> ReplyMessageNotFound(response, plainAnswer, message, cause)
|
||||||
else -> RequestException(response, message, cause)
|
else -> RequestException(response, plainAnswer, message, cause)
|
||||||
}
|
}
|
||||||
|
|
||||||
open class RequestException internal constructor(
|
open class RequestException internal constructor(
|
||||||
val response: Response<*>,
|
val response: Response<*>,
|
||||||
|
val plainAnswer: String,
|
||||||
message: String? = null,
|
message: String? = null,
|
||||||
cause: Throwable? = null
|
cause: Throwable? = null
|
||||||
) : IOException(
|
) : IOException(
|
||||||
|
Loading…
Reference in New Issue
Block a user