mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-03 23:29:33 +00:00
0.20.2 - MessageIsNotModifierException
This commit is contained in:
@@ -8,11 +8,14 @@ fun newRequestException(
|
||||
plainAnswer: String,
|
||||
message: String? = null,
|
||||
cause: Throwable? = null
|
||||
) = when (response.description) {
|
||||
"Bad Request: reply message not found" -> ReplyMessageNotFoundException(response, plainAnswer, message, cause)
|
||||
"Unauthorized" -> UnauthorizedException(response, plainAnswer, message, cause)
|
||||
else -> CommonRequestException(response, plainAnswer, message, cause)
|
||||
}
|
||||
) = response.description ?.let { description ->
|
||||
when {
|
||||
description == "Bad Request: reply message not found" -> ReplyMessageNotFoundException(response, plainAnswer, message, cause)
|
||||
description.contains("Bad Request: message is not modified") -> MessageIsNotModifierException(response, plainAnswer, message, cause)
|
||||
description == "Unauthorized" -> UnauthorizedException(response, plainAnswer, message, cause)
|
||||
else -> null
|
||||
}
|
||||
} ?: CommonRequestException(response, plainAnswer, message, cause)
|
||||
|
||||
sealed class RequestException constructor(
|
||||
val response: Response,
|
||||
@@ -32,3 +35,6 @@ class UnauthorizedException(response: Response, plainAnswer: String, message: St
|
||||
|
||||
class ReplyMessageNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||
RequestException(response, plainAnswer, message, cause)
|
||||
|
||||
class MessageIsNotModifierException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
|
||||
RequestException(response, plainAnswer, message, cause)
|
||||
|
Reference in New Issue
Block a user