diff --git a/src/errors.rs b/src/errors.rs
index 7d271042..dc3ff738 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -1,6 +1,7 @@
use reqwest::StatusCode;
//
+/// An error occurred after downloading a file.
#[derive(Debug, Error, From)]
pub enum DownloadError {
#[error("A network error: {0}")]
@@ -13,6 +14,7 @@ pub enum DownloadError {
//
//
+/// An error occurred after making a request to Telegram.
#[derive(Debug, Error)]
pub enum RequestError {
#[error("A Telegram's error #{status_code}: {kind:?}")]
@@ -27,7 +29,7 @@ pub enum RequestError {
MigrateToChatId(i64),
/// In case of exceeding flood control, the number of seconds left to wait
- /// before the request can be repeated
+ /// before the request can be repeated.
#[error("Retry after {0} seconds")]
RetryAfter(i32),
@@ -40,13 +42,14 @@ pub enum RequestError {
//
+/// A kind of an API error returned from Telegram.
#[derive(Debug, Deserialize, PartialEq, Copy, Hash, Eq, Clone)]
pub enum ApiErrorKind {
/// Occurs when the bot tries to send message to user who blocked the bot.
#[serde(rename = "Forbidden: bot was blocked by the user")]
BotBlocked,
- /// Occurs when bot tries to modify a message without modification content
+ /// Occurs when bot tries to modify a message without modification content.
///
/// May happen in methods:
/// 1. [`EditMessageText`]
@@ -57,7 +60,7 @@ pub enum ApiErrorKind {
as a current content and reply markup of the message")]
MessageNotModified,
- /// Occurs when bot tries to forward or delete a message which was deleted
+ /// Occurs when bot tries to forward or delete a message which was deleted.
///
/// May happen in methods:
/// 1. [`ForwardMessage`]
@@ -68,7 +71,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: MESSAGE_ID_INVALID")]
MessageIdInvalid,
- /// Occurs when bot tries to forward a message which does not exists
+ /// Occurs when bot tries to forward a message which does not exists.
///
/// May happen in methods:
/// 1. [`ForwardMessage`]
@@ -77,7 +80,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: message to forward not found")]
MessageToForwardNotFound,
- /// Occurs when bot tries to delete a message which does not exists
+ /// Occurs when bot tries to delete a message which does not exists.
///
/// May happen in methods:
/// 1. [`DeleteMessage`]
@@ -86,7 +89,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: message to delete not found")]
MessageToDeleteNotFound,
- /// Occurs when bot tries to send a text message without text
+ /// Occurs when bot tries to send a text message without text.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -95,7 +98,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: message text is empty")]
MessageTextIsEmpty,
- /// Occurs when bot tries to edit a message after long time
+ /// Occurs when bot tries to edit a message after long time.
///
/// May happen in methods:
/// 1. [`EditMessageText`]
@@ -105,7 +108,7 @@ pub enum ApiErrorKind {
MessageCantBeEdited,
/// Occurs when bot tries to delete a someone else's message in group where
- /// it does not have enough rights
+ /// it does not have enough rights.
///
/// May happen in methods:
/// 1. [`DeleteMessage`]
@@ -114,7 +117,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: message can't be deleted")]
MessageCantBeDeleted,
- /// Occurs when bot tries to edit a message which does not exists
+ /// Occurs when bot tries to edit a message which does not exists.
///
/// May happen in methods:
/// 1. [`EditMessageText`]
@@ -123,7 +126,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: message to edit not found")]
MessageToEditNotFound,
- /// Occurs when bot tries to reply to a message which does not exists
+ /// Occurs when bot tries to reply to a message which does not exists.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -137,7 +140,7 @@ pub enum ApiErrorKind {
MessageIdentifierNotSpecified,
/// Occurs when bot tries to send a message with text size greater then
- /// 4096 symbols
+ /// 4096 symbols.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -146,7 +149,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: message is too long")]
MessageIsTooLong,
- /// Occurs when bot tries to send media group with more than 10 items
+ /// Occurs when bot tries to send media group with more than 10 items.
///
/// May happen in methods:
/// 1. [`SendMediaGroup`]
@@ -155,7 +158,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: Too much messages to send as an album")]
ToMuchMessages,
- /// Occurs when bot tries to stop poll that has already been stopped
+ /// Occurs when bot tries to stop poll that has already been stopped.
///
/// May happen in methods:
/// 1. [`SendPoll`]
@@ -164,7 +167,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: poll has already been closed")]
PollHasAlreadyClosed,
- /// Occurs when bot tries to send poll with less than 2 options
+ /// Occurs when bot tries to send poll with less than 2 options.
///
/// May happen in methods:
/// 1. [`SendPoll`]
@@ -173,7 +176,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: poll must have at least 2 option")]
PollMustHaveMoreOptions,
- /// Occurs when bot tries to send poll with more than 10 options
+ /// Occurs when bot tries to send poll with more than 10 options.
///
/// May happen in methods:
/// 1. [`SendPoll`]
@@ -182,7 +185,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: poll can't have more than 10 options")]
PollCantHaveMoreOptions,
- /// Occurs when bot tries to send poll with empty option (without text)
+ /// Occurs when bot tries to send poll with empty option (without text).
///
/// May happen in methods:
/// 1. [`SendPoll`]
@@ -191,7 +194,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: poll options must be non-empty")]
PollOptionsMustBeNonEmpty,
- /// Occurs when bot tries to send poll with empty question (without text)
+ /// Occurs when bot tries to send poll with empty question (without text).
///
/// May happen in methods:
/// 1. [`SendPoll`]
@@ -201,7 +204,7 @@ pub enum ApiErrorKind {
PollQuestionMustBeNonEmpty,
/// Occurs when bot tries to send poll with total size of options more than
- /// 100 symbols
+ /// 100 symbols.
///
/// May happen in methods:
/// 1. [`SendPoll`]
@@ -211,7 +214,7 @@ pub enum ApiErrorKind {
PollOptionsLengthTooLong,
/// Occurs when bot tries to send poll with question size more than 255
- /// symbols
+ /// symbols.
///
/// May happen in methods:
/// 1. [`SendPoll`]
@@ -220,7 +223,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: poll question length must not exceed 255")]
PollQuestionLengthTooLong,
- /// Occurs when bot tries to stop poll with message without poll
+ /// Occurs when bot tries to stop poll with message without poll.
///
/// May happen in methods:
/// 1. [`StopPoll`]
@@ -229,7 +232,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: message with poll to stop not found")]
MessageWithPollNotFound,
- /// Occurs when bot tries to stop poll with message without poll
+ /// Occurs when bot tries to stop poll with message without poll.
///
/// May happen in methods:
/// 1. [`StopPoll`]
@@ -239,7 +242,7 @@ pub enum ApiErrorKind {
MessageIsNotAPoll,
/// Occurs when bot tries to send a message to chat in which it is not a
- /// member
+ /// member.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -248,7 +251,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: chat not found")]
ChatNotFound,
- /// Occurs when bot tries to send method with unknown user_id
+ /// Occurs when bot tries to send method with unknown user_id.
///
/// May happen in methods:
/// 1. [`getUserProfilePhotos`]
@@ -259,7 +262,7 @@ pub enum ApiErrorKind {
UserNotFound,
/// Occurs when bot tries to send [`SetChatDescription`] with same text as
- /// in the current description
+ /// in the current description.
///
/// May happen in methods:
/// 1. [`SetChatDescription`]
@@ -268,7 +271,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: chat description is not modified")]
ChatDescriptionIsNotModified,
- /// Occurs when bot tries to answer to query after timeout expire
+ /// Occurs when bot tries to answer to query after timeout expire.
///
/// May happen in methods:
/// 1. [`AnswerCallbackQuery`]
@@ -279,7 +282,7 @@ pub enum ApiErrorKind {
InvalidQueryID,
/// Occurs when bot tries to send InlineKeyboardMarkup with invalid button
- /// url
+ /// url.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -288,7 +291,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: BUTTON_URL_INVALID")]
ButtonURLInvalid,
- /// Occurs when bot tries to send button with data size more than 64 bytes
+ /// Occurs when bot tries to send button with data size more than 64 bytes.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -297,7 +300,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: BUTTON_DATA_INVALID")]
ButtonDataInvalid,
- /// Occurs when bot tries to send button with data size == 0
+ /// Occurs when bot tries to send button with data size == 0.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -307,7 +310,7 @@ pub enum ApiErrorKind {
buttons are unallowed in the inline keyboard")]
TextButtonsAreUnallowed,
- /// Occurs when bot tries to get file by wrong file id
+ /// Occurs when bot tries to get file by wrong file id.
///
/// May happen in methods:
/// 1. [`GetFile`]
@@ -316,7 +319,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: wrong file id")]
WrongFileID,
- /// Occurs when bot tries to do some with group which was deactivated
+ /// Occurs when bot tries to do some with group which was deactivated.
#[serde(rename = "Bad Request: group is deactivated")]
GroupDeactivated,
@@ -329,7 +332,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: Photo should be uploaded as an InputFile")]
PhotoAsInputFileRequired,
- /// Occurs when bot tries to add sticker to stickerset by invalid name
+ /// Occurs when bot tries to add sticker to stickerset by invalid name.
///
/// May happen in methods:
/// 1. [`AddStickerToSet`]
@@ -339,7 +342,7 @@ pub enum ApiErrorKind {
InvalidStickersSet,
/// Occurs when bot tries to pin a message without rights to pin in this
- /// chat
+ /// chat.
///
/// May happen in methods:
/// 1. [`PinMessage`]
@@ -349,12 +352,12 @@ pub enum ApiErrorKind {
NotEnoughRightsToPinMessage,
/// Occurs when bot tries to use method in group which is allowed only in a
- /// supergroup or channel
+ /// supergroup or channel.
#[serde(rename = "Bad Request: method is available only for supergroups \
and channel")]
MethodNotAvailableInPrivateChats,
- /// Occurs when bot tries to demote chat creator
+ /// Occurs when bot tries to demote chat creator.
///
/// May happen in methods:
/// 1. [`PromoteChatMember`]
@@ -363,7 +366,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: can't demote chat creator")]
CantDemoteChatCreator,
- /// Occurs when bot tries to restrict self in group chats
+ /// Occurs when bot tries to restrict self in group chats.
///
/// May happen in methods:
/// 1. [`RestrictChatMember`]
@@ -373,7 +376,7 @@ pub enum ApiErrorKind {
CantRestrictSelf,
/// Occurs when bot tries to restrict chat member without rights to
- /// restrict in this chat
+ /// restrict in this chat.
///
/// May happen in methods:
/// 1. [`RestrictChatMember`]
@@ -383,7 +386,7 @@ pub enum ApiErrorKind {
chat member")]
NotEnoughRightsToRestrict,
- /// Occurs when bot tries set webhook to protocol other than HTTPS
+ /// Occurs when bot tries set webhook to protocol other than HTTPS.
///
/// May happen in methods:
/// 1. [`SetWebhook`]
@@ -394,7 +397,7 @@ pub enum ApiErrorKind {
WebhookRequireHTTPS,
/// Occurs when bot tries to set webhook to port other than 80, 88, 443 or
- /// 8443
+ /// 8443.
///
/// May happen in methods:
/// 1. [`SetWebhook`]
@@ -404,7 +407,7 @@ pub enum ApiErrorKind {
on ports 80, 88, 443 or 8443")]
BadWebhookPort,
- /// Occurs when bot tries to set webhook to unknown host
+ /// Occurs when bot tries to set webhook to unknown host.
///
/// May happen in methods:
/// 1. [`SetWebhook`]
@@ -414,7 +417,7 @@ pub enum ApiErrorKind {
Name or service not known")]
UnknownHost,
- /// Occurs when bot tries to set webhook to invalid URL
+ /// Occurs when bot tries to set webhook to invalid URL.
///
/// May happen in methods:
/// 1. [`SetWebhook`]
@@ -423,7 +426,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: can't parse URL")]
CantParseUrl,
- /// Occurs when bot tries to send message with unfinished entities
+ /// Occurs when bot tries to send message with unfinished entities.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -432,7 +435,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: can't parse entities")]
CantParseEntities,
- /// Occurs when bot tries to use getUpdates while webhook is active
+ /// Occurs when bot tries to use getUpdates while webhook is active.
///
/// May happen in methods:
/// 1. [`GetUpdates`]
@@ -441,7 +444,7 @@ pub enum ApiErrorKind {
#[serde(rename = "can't use getUpdates method while webhook is active")]
CantGetUpdates,
- /// Occurs when bot tries to do some in group where bot was kicked
+ /// Occurs when bot tries to do some in group where bot was kicked.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -450,7 +453,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Unauthorized: bot was kicked from a chat")]
BotKicked,
- /// Occurs when bot tries to send message to deactivated user
+ /// Occurs when bot tries to send message to deactivated user.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -459,7 +462,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Unauthorized: user is deactivated")]
UserDeactivated,
- /// Occurs when you tries to initiate conversation with a user
+ /// Occurs when you tries to initiate conversation with a user.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -470,7 +473,7 @@ pub enum ApiErrorKind {
)]
CantInitiateConversation,
- /// Occurs when you tries to send message to bot
+ /// Occurs when you tries to send message to bot.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -479,7 +482,7 @@ pub enum ApiErrorKind {
#[serde(rename = "Unauthorized: bot can't send messages to bots")]
CantTalkWithBots,
- /// Occurs when bot tries to send button with invalid http url
+ /// Occurs when bot tries to send button with invalid http url.
///
/// May happen in methods:
/// 1. [`SendMessage`]
@@ -488,8 +491,8 @@ pub enum ApiErrorKind {
#[serde(rename = "Bad Request: wrong HTTP URL")]
WrongHTTPurl,
- /// Occurs when bot tries GetUpdate before the timeout.
- /// Make sure that only one Updater is running.
+ /// Occurs when bot tries GetUpdate before the timeout. Make sure that only
+ /// one Updater is running.
///
/// May happen in methods:
/// 1. [`GetUpdates`]
@@ -499,7 +502,7 @@ pub enum ApiErrorKind {
make sure that only one bot instance is running")]
TerminatedByOtherGetUpdates,
- /// Occurs when bot tries to get file by invalid file id
+ /// Occurs when bot tries to get file by invalid file id.
///
/// May happen in methods:
/// 1. [`GetFile`]