mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-23 00:57:13 +00:00
replace of exceptions
This commit is contained in:
parent
9f3d678528
commit
1dc80f6929
@ -9,6 +9,7 @@
|
||||
* Update some types and requests according to abstractions replacing
|
||||
* Add all `InlineQueryResult`, `InputMessageContent` and other inline mode types
|
||||
* Fixes in edition of inline messages and their result types
|
||||
* Replace basic exception and add `ReplyMessageNotFound` exception
|
||||
|
||||
## 0.9.0
|
||||
|
||||
|
@ -3,7 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.BaseRequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base.MultipartRequestCallFactory
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base.SimpleRequestCallFactory
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestException
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.RequestException
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.newRequestException
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.EmptyLimiter
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.settings.limiters.RequestLimiter
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
@ -75,7 +76,7 @@ class KtorRequestsExecutor(
|
||||
null
|
||||
}
|
||||
} ?: call.let {
|
||||
throw RequestException(
|
||||
throw newRequestException(
|
||||
responseObject,
|
||||
"Can't get result object"
|
||||
)
|
||||
|
@ -1,13 +1,14 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.RequestException
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
import java.io.IOException
|
||||
|
||||
class RequestException(
|
||||
val response: Response<*>,
|
||||
message: String? = null,
|
||||
cause: Throwable? = null
|
||||
) : IOException(
|
||||
message,
|
||||
cause
|
||||
)
|
||||
@Deprecated(
|
||||
"Replaced to another package",
|
||||
ReplaceWith(
|
||||
"RequestException",
|
||||
"com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.RequestException"
|
||||
)
|
||||
)
|
||||
typealias RequestException = RequestException
|
@ -1,5 +1,6 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.RequestException
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
|
||||
interface RequestsExecutor {
|
||||
|
@ -0,0 +1,6 @@
|
||||
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)
|
@ -0,0 +1,22 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.Response
|
||||
import java.io.IOException
|
||||
|
||||
fun newRequestException(
|
||||
response: Response<*>,
|
||||
message: String? = null,
|
||||
cause: Throwable? = null
|
||||
) = when (response.description) {
|
||||
"Bad Request: reply message not found" -> ReplyMessageNotFound(response, message, cause)
|
||||
else -> RequestException(response, message, cause)
|
||||
}
|
||||
|
||||
open class RequestException internal constructor(
|
||||
val response: Response<*>,
|
||||
message: String? = null,
|
||||
cause: Throwable? = null
|
||||
) : IOException(
|
||||
message,
|
||||
cause
|
||||
)
|
@ -1,6 +1,6 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestException
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.RequestException
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||
|
Loading…
Reference in New Issue
Block a user