mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-24 15:49:27 +01:00
Merge branch 'master' into impl_payload_macro
This commit is contained in:
commit
a917363da0
3 changed files with 430 additions and 507 deletions
845
src/errors.rs
845
src/errors.rs
|
@ -57,480 +57,475 @@ pub enum RequestError {
|
||||||
Io(#[source] io::Error),
|
Io(#[source] io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
serde_or_unknown! {
|
/// A kind of an API error.
|
||||||
#[unknown_mod = api_error_internals]
|
#[derive(Debug, Deserialize, PartialEq, Hash, Eq, Clone)]
|
||||||
#[unknown_kind = Kind]
|
#[serde(field_identifier)]
|
||||||
#[unknown_path = "api_error_internals::Kind"]
|
pub enum ApiError {
|
||||||
|
/// Occurs when the bot tries to send message to user who blocked the bot.
|
||||||
|
#[serde(rename = "Forbidden: bot was blocked by the user")]
|
||||||
|
BotBlocked,
|
||||||
|
|
||||||
/// A kind of an API error.
|
/// Occurs when bot tries to modify a message without modification content.
|
||||||
#[derive(Debug, Deserialize, PartialEq, Hash, Eq, Clone)]
|
///
|
||||||
pub enum ApiError {
|
/// May happen in methods:
|
||||||
#[unknown]
|
/// 1. [`EditMessageText`]
|
||||||
/// Error which is not known to `teloxide`.
|
///
|
||||||
///
|
/// [`EditMessageText`]: crate::requests::EditMessageText
|
||||||
/// If you've received this error, please [open an issue] with the description of the error.
|
#[serde(rename = "Bad Request: message is not modified: specified new message content and \
|
||||||
///
|
reply markup are exactly the same as a current content and reply markup \
|
||||||
/// [open an issue]: https://github.com/teloxide/teloxide/issues/new
|
of the message")]
|
||||||
Unknown(String),
|
MessageNotModified,
|
||||||
|
|
||||||
/// Occurs when the bot tries to send message to user who blocked the bot.
|
/// Occurs when bot tries to forward or delete a message which was deleted.
|
||||||
#[serde(rename = "Forbidden: bot was blocked by the user")]
|
///
|
||||||
BotBlocked,
|
/// May happen in methods:
|
||||||
|
/// 1. [`ForwardMessage`]
|
||||||
|
/// 2. [`DeleteMessage`]
|
||||||
|
///
|
||||||
|
/// [`ForwardMessage`]: crate::requests::ForwardMessage
|
||||||
|
/// [`DeleteMessage`]: crate::requests::DeleteMessage
|
||||||
|
#[serde(rename = "Bad Request: MESSAGE_ID_INVALID")]
|
||||||
|
MessageIdInvalid,
|
||||||
|
|
||||||
/// Occurs when bot tries to modify a message without modification content.
|
/// Occurs when bot tries to forward a message which does not exists.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`EditMessageText`]
|
/// 1. [`ForwardMessage`]
|
||||||
///
|
///
|
||||||
/// [`EditMessageText`]: crate::requests::EditMessageText
|
/// [`ForwardMessage`]: crate::requests::ForwardMessage
|
||||||
#[serde(rename = "Bad Request: message is not modified: specified new message content and \
|
#[serde(rename = "Bad Request: message to forward not found")]
|
||||||
reply markup are exactly the same as a current content and reply markup \
|
MessageToForwardNotFound,
|
||||||
of the message")]
|
|
||||||
MessageNotModified,
|
|
||||||
|
|
||||||
/// Occurs when bot tries to forward or delete a message which was deleted.
|
/// Occurs when bot tries to delete a message which does not exists.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`ForwardMessage`]
|
/// 1. [`DeleteMessage`]
|
||||||
/// 2. [`DeleteMessage`]
|
///
|
||||||
///
|
/// [`DeleteMessage`]: crate::requests::DeleteMessage
|
||||||
/// [`ForwardMessage`]: crate::requests::ForwardMessage
|
#[serde(rename = "Bad Request: message to delete not found")]
|
||||||
/// [`DeleteMessage`]: crate::requests::DeleteMessage
|
MessageToDeleteNotFound,
|
||||||
#[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 send a text message without text.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`ForwardMessage`]
|
/// 1. [`SendMessage`]
|
||||||
///
|
///
|
||||||
/// [`ForwardMessage`]: crate::requests::ForwardMessage
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
#[serde(rename = "Bad Request: message to forward not found")]
|
#[serde(rename = "Bad Request: message text is empty")]
|
||||||
MessageToForwardNotFound,
|
MessageTextIsEmpty,
|
||||||
|
|
||||||
/// Occurs when bot tries to delete a message which does not exists.
|
/// Occurs when bot tries to edit a message after long time.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`DeleteMessage`]
|
/// 1. [`EditMessageText`]
|
||||||
///
|
///
|
||||||
/// [`DeleteMessage`]: crate::requests::DeleteMessage
|
/// [`EditMessageText`]: crate::requests::EditMessageText
|
||||||
#[serde(rename = "Bad Request: message to delete not found")]
|
#[serde(rename = "Bad Request: message can't be edited")]
|
||||||
MessageToDeleteNotFound,
|
MessageCantBeEdited,
|
||||||
|
|
||||||
/// Occurs when bot tries to send a text message without text.
|
/// Occurs when bot tries to delete a someone else's message in group where
|
||||||
///
|
/// it does not have enough rights.
|
||||||
/// May happen in methods:
|
///
|
||||||
/// 1. [`SendMessage`]
|
/// May happen in methods:
|
||||||
///
|
/// 1. [`DeleteMessage`]
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
///
|
||||||
#[serde(rename = "Bad Request: message text is empty")]
|
/// [`DeleteMessage`]: crate::requests::DeleteMessage
|
||||||
MessageTextIsEmpty,
|
#[serde(rename = "Bad Request: message can't be deleted")]
|
||||||
|
MessageCantBeDeleted,
|
||||||
|
|
||||||
/// Occurs when bot tries to edit a message after long time.
|
/// Occurs when bot tries to edit a message which does not exists.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`EditMessageText`]
|
/// 1. [`EditMessageText`]
|
||||||
///
|
///
|
||||||
/// [`EditMessageText`]: crate::requests::EditMessageText
|
/// [`EditMessageText`]: crate::requests::EditMessageText
|
||||||
#[serde(rename = "Bad Request: message can't be edited")]
|
#[serde(rename = "Bad Request: message to edit not found")]
|
||||||
MessageCantBeEdited,
|
MessageToEditNotFound,
|
||||||
|
|
||||||
/// Occurs when bot tries to delete a someone else's message in group where
|
/// Occurs when bot tries to reply to a message which does not exists.
|
||||||
/// it does not have enough rights.
|
///
|
||||||
///
|
/// May happen in methods:
|
||||||
/// May happen in methods:
|
/// 1. [`SendMessage`]
|
||||||
/// 1. [`DeleteMessage`]
|
///
|
||||||
///
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
/// [`DeleteMessage`]: crate::requests::DeleteMessage
|
#[serde(rename = "Bad Request: reply message not found")]
|
||||||
#[serde(rename = "Bad Request: message can't be deleted")]
|
MessageToReplyNotFound,
|
||||||
MessageCantBeDeleted,
|
|
||||||
|
|
||||||
/// Occurs when bot tries to edit a message which does not exists.
|
/// Occurs when bot tries to
|
||||||
///
|
#[serde(rename = "Bad Request: message identifier is not specified")]
|
||||||
/// May happen in methods:
|
MessageIdentifierNotSpecified,
|
||||||
/// 1. [`EditMessageText`]
|
|
||||||
///
|
|
||||||
/// [`EditMessageText`]: crate::requests::EditMessageText
|
|
||||||
#[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 send a message with text size greater then
|
||||||
///
|
/// 4096 symbols.
|
||||||
/// May happen in methods:
|
///
|
||||||
/// 1. [`SendMessage`]
|
/// May happen in methods:
|
||||||
///
|
/// 1. [`SendMessage`]
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
///
|
||||||
#[serde(rename = "Bad Request: reply message not found")]
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
MessageToReplyNotFound,
|
#[serde(rename = "Bad Request: message is too long")]
|
||||||
|
MessageIsTooLong,
|
||||||
|
|
||||||
/// Occurs when bot tries to
|
/// Occurs when bot tries to send media group with more than 10 items.
|
||||||
#[serde(rename = "Bad Request: message identifier is not specified")]
|
///
|
||||||
MessageIdentifierNotSpecified,
|
/// May happen in methods:
|
||||||
|
/// 1. [`SendMediaGroup`]
|
||||||
|
///
|
||||||
|
/// [`SendMediaGroup`]: crate::requests::SendMediaGroup
|
||||||
|
#[serde(rename = "Bad Request: Too much messages to send as an album")]
|
||||||
|
ToMuchMessages,
|
||||||
|
|
||||||
/// Occurs when bot tries to send a message with text size greater then
|
/// Occurs when bot tries to stop poll that has already been stopped.
|
||||||
/// 4096 symbols.
|
///
|
||||||
///
|
/// May happen in methods:
|
||||||
/// May happen in methods:
|
/// 1. [`SendPoll`]
|
||||||
/// 1. [`SendMessage`]
|
///
|
||||||
///
|
/// [`SendPoll`]: crate::requests::SendPoll
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
#[serde(rename = "Bad Request: poll has already been closed")]
|
||||||
#[serde(rename = "Bad Request: message is too long")]
|
PollHasAlreadyClosed,
|
||||||
MessageIsTooLong,
|
|
||||||
|
|
||||||
/// Occurs when bot tries to send media group with more than 10 items.
|
/// Occurs when bot tries to send poll with less than 2 options.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SendMediaGroup`]
|
/// 1. [`SendPoll`]
|
||||||
///
|
///
|
||||||
/// [`SendMediaGroup`]: crate::requests::SendMediaGroup
|
/// [`SendPoll`]: crate::requests::SendPoll
|
||||||
#[serde(rename = "Bad Request: Too much messages to send as an album")]
|
#[serde(rename = "Bad Request: poll must have at least 2 option")]
|
||||||
ToMuchMessages,
|
PollMustHaveMoreOptions,
|
||||||
|
|
||||||
/// Occurs when bot tries to stop poll that has already been stopped.
|
/// Occurs when bot tries to send poll with more than 10 options.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SendPoll`]
|
/// 1. [`SendPoll`]
|
||||||
///
|
///
|
||||||
/// [`SendPoll`]: crate::requests::SendPoll
|
/// [`SendPoll`]: crate::requests::SendPoll
|
||||||
#[serde(rename = "Bad Request: poll has already been closed")]
|
#[serde(rename = "Bad Request: poll can't have more than 10 options")]
|
||||||
PollHasAlreadyClosed,
|
PollCantHaveMoreOptions,
|
||||||
|
|
||||||
/// Occurs when bot tries to send poll with less than 2 options.
|
/// Occurs when bot tries to send poll with empty option (without text).
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SendPoll`]
|
/// 1. [`SendPoll`]
|
||||||
///
|
///
|
||||||
/// [`SendPoll`]: crate::requests::SendPoll
|
/// [`SendPoll`]: crate::requests::SendPoll
|
||||||
#[serde(rename = "Bad Request: poll must have at least 2 option")]
|
#[serde(rename = "Bad Request: poll options must be non-empty")]
|
||||||
PollMustHaveMoreOptions,
|
PollOptionsMustBeNonEmpty,
|
||||||
|
|
||||||
/// Occurs when bot tries to send poll with more than 10 options.
|
/// Occurs when bot tries to send poll with empty question (without text).
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SendPoll`]
|
/// 1. [`SendPoll`]
|
||||||
///
|
///
|
||||||
/// [`SendPoll`]: crate::requests::SendPoll
|
/// [`SendPoll`]: crate::requests::SendPoll
|
||||||
#[serde(rename = "Bad Request: poll can't have more than 10 options")]
|
#[serde(rename = "Bad Request: poll question must be non-empty")]
|
||||||
PollCantHaveMoreOptions,
|
PollQuestionMustBeNonEmpty,
|
||||||
|
|
||||||
/// Occurs when bot tries to send poll with empty option (without text).
|
/// Occurs when bot tries to send poll with total size of options more than
|
||||||
///
|
/// 100 symbols.
|
||||||
/// May happen in methods:
|
///
|
||||||
/// 1. [`SendPoll`]
|
/// May happen in methods:
|
||||||
///
|
/// 1. [`SendPoll`]
|
||||||
/// [`SendPoll`]: crate::requests::SendPoll
|
///
|
||||||
#[serde(rename = "Bad Request: poll options must be non-empty")]
|
/// [`SendPoll`]: crate::requests::SendPoll
|
||||||
PollOptionsMustBeNonEmpty,
|
#[serde(rename = "Bad Request: poll options length must not exceed 100")]
|
||||||
|
PollOptionsLengthTooLong,
|
||||||
|
|
||||||
/// Occurs when bot tries to send poll with empty question (without text).
|
/// Occurs when bot tries to send poll with question size more than 255
|
||||||
///
|
/// symbols.
|
||||||
/// May happen in methods:
|
///
|
||||||
/// 1. [`SendPoll`]
|
/// May happen in methods:
|
||||||
///
|
/// 1. [`SendPoll`]
|
||||||
/// [`SendPoll`]: crate::requests::SendPoll
|
///
|
||||||
#[serde(rename = "Bad Request: poll question must be non-empty")]
|
/// [`SendPoll`]: crate::requests::SendPoll
|
||||||
PollQuestionMustBeNonEmpty,
|
#[serde(rename = "Bad Request: poll question length must not exceed 255")]
|
||||||
|
PollQuestionLengthTooLong,
|
||||||
|
|
||||||
/// Occurs when bot tries to send poll with total size of options more than
|
/// Occurs when bot tries to stop poll with message without poll.
|
||||||
/// 100 symbols.
|
///
|
||||||
///
|
/// May happen in methods:
|
||||||
/// May happen in methods:
|
/// 1. [`StopPoll`]
|
||||||
/// 1. [`SendPoll`]
|
///
|
||||||
///
|
/// [`StopPoll`]: crate::requests::StopPoll
|
||||||
/// [`SendPoll`]: crate::requests::SendPoll
|
#[serde(rename = "Bad Request: message with poll to stop not found")]
|
||||||
#[serde(rename = "Bad Request: poll options length must not exceed 100")]
|
MessageWithPollNotFound,
|
||||||
PollOptionsLengthTooLong,
|
|
||||||
|
|
||||||
/// Occurs when bot tries to send poll with question size more than 255
|
/// Occurs when bot tries to stop poll with message without poll.
|
||||||
/// symbols.
|
///
|
||||||
///
|
/// May happen in methods:
|
||||||
/// May happen in methods:
|
/// 1. [`StopPoll`]
|
||||||
/// 1. [`SendPoll`]
|
///
|
||||||
///
|
/// [`StopPoll`]: crate::requests::StopPoll
|
||||||
/// [`SendPoll`]: crate::requests::SendPoll
|
#[serde(rename = "Bad Request: message is not a poll")]
|
||||||
#[serde(rename = "Bad Request: poll question length must not exceed 255")]
|
MessageIsNotAPoll,
|
||||||
PollQuestionLengthTooLong,
|
|
||||||
|
|
||||||
/// Occurs when bot tries to stop poll with message without poll.
|
/// Occurs when bot tries to send a message to chat in which it is not a
|
||||||
///
|
/// member.
|
||||||
/// May happen in methods:
|
///
|
||||||
/// 1. [`StopPoll`]
|
/// May happen in methods:
|
||||||
///
|
/// 1. [`SendMessage`]
|
||||||
/// [`StopPoll`]: crate::requests::StopPoll
|
///
|
||||||
#[serde(rename = "Bad Request: message with poll to stop not found")]
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
MessageWithPollNotFound,
|
#[serde(rename = "Bad Request: chat not found")]
|
||||||
|
ChatNotFound,
|
||||||
|
|
||||||
/// Occurs when bot tries to stop poll with message without poll.
|
/// Occurs when bot tries to send method with unknown user_id.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`StopPoll`]
|
/// 1. [`getUserProfilePhotos`]
|
||||||
///
|
///
|
||||||
/// [`StopPoll`]: crate::requests::StopPoll
|
/// [`getUserProfilePhotos`]:
|
||||||
#[serde(rename = "Bad Request: message is not a poll")]
|
/// crate::requests::GetUserProfilePhotos
|
||||||
MessageIsNotAPoll,
|
#[serde(rename = "Bad Request: user not found")]
|
||||||
|
UserNotFound,
|
||||||
|
|
||||||
/// Occurs when bot tries to send a message to chat in which it is not a
|
/// Occurs when bot tries to send [`SetChatDescription`] with same text as
|
||||||
/// member.
|
/// in the current description.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SendMessage`]
|
/// 1. [`SetChatDescription`]
|
||||||
///
|
///
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
/// [`SetChatDescription`]: crate::requests::SetChatDescription
|
||||||
#[serde(rename = "Bad Request: chat not found")]
|
#[serde(rename = "Bad Request: chat description is not modified")]
|
||||||
ChatNotFound,
|
ChatDescriptionIsNotModified,
|
||||||
|
|
||||||
/// Occurs when bot tries to send method with unknown user_id.
|
/// Occurs when bot tries to answer to query after timeout expire.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`getUserProfilePhotos`]
|
/// 1. [`AnswerCallbackQuery`]
|
||||||
///
|
///
|
||||||
/// [`getUserProfilePhotos`]:
|
/// [`AnswerCallbackQuery`]: crate::requests::AnswerCallbackQuery
|
||||||
/// crate::requests::GetUserProfilePhotos
|
#[serde(rename = "Bad Request: query is too old and response timeout expired or query id is \
|
||||||
#[serde(rename = "Bad Request: user not found")]
|
invalid")]
|
||||||
UserNotFound,
|
InvalidQueryID,
|
||||||
|
|
||||||
/// Occurs when bot tries to send [`SetChatDescription`] with same text as
|
/// Occurs when bot tries to send InlineKeyboardMarkup with invalid button
|
||||||
/// in the current description.
|
/// url.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SetChatDescription`]
|
/// 1. [`SendMessage`]
|
||||||
///
|
///
|
||||||
/// [`SetChatDescription`]: crate::requests::SetChatDescription
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
#[serde(rename = "Bad Request: chat description is not modified")]
|
#[serde(rename = "Bad Request: BUTTON_URL_INVALID")]
|
||||||
ChatDescriptionIsNotModified,
|
ButtonURLInvalid,
|
||||||
|
|
||||||
/// Occurs when bot tries to answer to query after timeout expire.
|
/// Occurs when bot tries to send button with data size more than 64 bytes.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`AnswerCallbackQuery`]
|
/// 1. [`SendMessage`]
|
||||||
///
|
///
|
||||||
/// [`AnswerCallbackQuery`]: crate::requests::AnswerCallbackQuery
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
#[serde(rename = "Bad Request: query is too old and response timeout expired or query id is \
|
#[serde(rename = "Bad Request: BUTTON_DATA_INVALID")]
|
||||||
invalid")]
|
ButtonDataInvalid,
|
||||||
InvalidQueryID,
|
|
||||||
|
|
||||||
/// Occurs when bot tries to send InlineKeyboardMarkup with invalid button
|
/// Occurs when bot tries to send button with data size == 0.
|
||||||
/// url.
|
///
|
||||||
///
|
/// May happen in methods:
|
||||||
/// May happen in methods:
|
/// 1. [`SendMessage`]
|
||||||
/// 1. [`SendMessage`]
|
///
|
||||||
///
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
#[serde(rename = "Bad Request: can't parse inline keyboard button: Text buttons are \
|
||||||
#[serde(rename = "Bad Request: BUTTON_URL_INVALID")]
|
unallowed in the inline keyboard")]
|
||||||
ButtonURLInvalid,
|
TextButtonsAreUnallowed,
|
||||||
|
|
||||||
/// Occurs when bot tries to send button with data size more than 64 bytes.
|
/// Occurs when bot tries to get file by wrong file id.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SendMessage`]
|
/// 1. [`GetFile`]
|
||||||
///
|
///
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
/// [`GetFile`]: crate::requests::GetFile
|
||||||
#[serde(rename = "Bad Request: BUTTON_DATA_INVALID")]
|
#[serde(rename = "Bad Request: wrong file id")]
|
||||||
ButtonDataInvalid,
|
WrongFileID,
|
||||||
|
|
||||||
/// Occurs when bot tries to send button with data size == 0.
|
/// Occurs when bot tries to do some with group which was deactivated.
|
||||||
///
|
#[serde(rename = "Bad Request: group is deactivated")]
|
||||||
/// May happen in methods:
|
GroupDeactivated,
|
||||||
/// 1. [`SendMessage`]
|
|
||||||
///
|
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
|
||||||
#[serde(rename = "Bad Request: can't parse inline keyboard button: Text buttons are \
|
|
||||||
unallowed in the inline keyboard")]
|
|
||||||
TextButtonsAreUnallowed,
|
|
||||||
|
|
||||||
/// Occurs when bot tries to get file by wrong file id.
|
/// Occurs when bot tries to set chat photo from file ID
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`GetFile`]
|
/// 1. [`SetChatPhoto`]
|
||||||
///
|
///
|
||||||
/// [`GetFile`]: crate::requests::GetFile
|
/// [`SetChatPhoto`]: crate::requests::SetChatPhoto
|
||||||
#[serde(rename = "Bad Request: wrong file id")]
|
#[serde(rename = "Bad Request: Photo should be uploaded as an InputFile")]
|
||||||
WrongFileID,
|
PhotoAsInputFileRequired,
|
||||||
|
|
||||||
/// Occurs when bot tries to do some with group which was deactivated.
|
/// Occurs when bot tries to add sticker to stickerset by invalid name.
|
||||||
#[serde(rename = "Bad Request: group is deactivated")]
|
///
|
||||||
GroupDeactivated,
|
/// May happen in methods:
|
||||||
|
/// 1. [`AddStickerToSet`]
|
||||||
|
///
|
||||||
|
/// [`AddStickerToSet`]: crate::requests::AddStickerToSet
|
||||||
|
#[serde(rename = "Bad Request: STICKERSET_INVALID")]
|
||||||
|
InvalidStickersSet,
|
||||||
|
|
||||||
/// Occurs when bot tries to set chat photo from file ID
|
/// Occurs when bot tries to pin a message without rights to pin in this
|
||||||
///
|
/// chat.
|
||||||
/// May happen in methods:
|
///
|
||||||
/// 1. [`SetChatPhoto`]
|
/// May happen in methods:
|
||||||
///
|
/// 1. [`PinChatMessage`]
|
||||||
/// [`SetChatPhoto`]: crate::requests::SetChatPhoto
|
///
|
||||||
#[serde(rename = "Bad Request: Photo should be uploaded as an InputFile")]
|
/// [`PinChatMessage`]: crate::requests::PinChatMessage
|
||||||
PhotoAsInputFileRequired,
|
#[serde(rename = "Bad Request: not enough rights to pin a message")]
|
||||||
|
NotEnoughRightsToPinMessage,
|
||||||
|
|
||||||
/// Occurs when bot tries to add sticker to stickerset by invalid name.
|
/// Occurs when bot tries to use method in group which is allowed only in a
|
||||||
///
|
/// supergroup or channel.
|
||||||
/// May happen in methods:
|
#[serde(rename = "Bad Request: method is available only for supergroups and channel")]
|
||||||
/// 1. [`AddStickerToSet`]
|
MethodNotAvailableInPrivateChats,
|
||||||
///
|
|
||||||
/// [`AddStickerToSet`]: crate::requests::AddStickerToSet
|
|
||||||
#[serde(rename = "Bad Request: STICKERSET_INVALID")]
|
|
||||||
InvalidStickersSet,
|
|
||||||
|
|
||||||
/// Occurs when bot tries to pin a message without rights to pin in this
|
/// Occurs when bot tries to demote chat creator.
|
||||||
/// chat.
|
///
|
||||||
///
|
/// May happen in methods:
|
||||||
/// May happen in methods:
|
/// 1. [`PromoteChatMember`]
|
||||||
/// 1. [`PinChatMessage`]
|
///
|
||||||
///
|
/// [`PromoteChatMember`]: crate::requests::PromoteChatMember
|
||||||
/// [`PinChatMessage`]: crate::requests::PinChatMessage
|
#[serde(rename = "Bad Request: can't demote chat creator")]
|
||||||
#[serde(rename = "Bad Request: not enough rights to pin a message")]
|
CantDemoteChatCreator,
|
||||||
NotEnoughRightsToPinMessage,
|
|
||||||
|
|
||||||
/// Occurs when bot tries to use method in group which is allowed only in a
|
/// Occurs when bot tries to restrict self in group chats.
|
||||||
/// supergroup or channel.
|
///
|
||||||
#[serde(rename = "Bad Request: method is available only for supergroups and channel")]
|
/// May happen in methods:
|
||||||
MethodNotAvailableInPrivateChats,
|
/// 1. [`RestrictChatMember`]
|
||||||
|
///
|
||||||
|
/// [`RestrictChatMember`]: crate::requests::RestrictChatMember
|
||||||
|
#[serde(rename = "Bad Request: can't restrict self")]
|
||||||
|
CantRestrictSelf,
|
||||||
|
|
||||||
/// Occurs when bot tries to demote chat creator.
|
/// Occurs when bot tries to restrict chat member without rights to
|
||||||
///
|
/// restrict in this chat.
|
||||||
/// May happen in methods:
|
///
|
||||||
/// 1. [`PromoteChatMember`]
|
/// May happen in methods:
|
||||||
///
|
/// 1. [`RestrictChatMember`]
|
||||||
/// [`PromoteChatMember`]: crate::requests::PromoteChatMember
|
///
|
||||||
#[serde(rename = "Bad Request: can't demote chat creator")]
|
/// [`RestrictChatMember`]: crate::requests::RestrictChatMember
|
||||||
CantDemoteChatCreator,
|
#[serde(rename = "Bad Request: not enough rights to restrict/unrestrict chat member")]
|
||||||
|
NotEnoughRightsToRestrict,
|
||||||
|
|
||||||
/// Occurs when bot tries to restrict self in group chats.
|
/// Occurs when bot tries set webhook to protocol other than HTTPS.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`RestrictChatMember`]
|
/// 1. [`SetWebhook`]
|
||||||
///
|
///
|
||||||
/// [`RestrictChatMember`]: crate::requests::RestrictChatMember
|
/// [`SetWebhook`]: crate::requests::SetWebhook
|
||||||
#[serde(rename = "Bad Request: can't restrict self")]
|
#[serde(rename = "Bad Request: bad webhook: HTTPS url must be provided for webhook")]
|
||||||
CantRestrictSelf,
|
WebhookRequireHTTPS,
|
||||||
|
|
||||||
/// Occurs when bot tries to restrict chat member without rights to
|
/// Occurs when bot tries to set webhook to port other than 80, 88, 443 or
|
||||||
/// restrict in this chat.
|
/// 8443.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`RestrictChatMember`]
|
/// 1. [`SetWebhook`]
|
||||||
///
|
///
|
||||||
/// [`RestrictChatMember`]: crate::requests::RestrictChatMember
|
/// [`SetWebhook`]: crate::requests::SetWebhook
|
||||||
#[serde(rename = "Bad Request: not enough rights to restrict/unrestrict chat member")]
|
#[serde(rename = "Bad Request: bad webhook: Webhook can be set up only on ports 80, 88, 443 \
|
||||||
NotEnoughRightsToRestrict,
|
or 8443")]
|
||||||
|
BadWebhookPort,
|
||||||
|
|
||||||
/// Occurs when bot tries set webhook to protocol other than HTTPS.
|
/// Occurs when bot tries to set webhook to unknown host.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SetWebhook`]
|
/// 1. [`SetWebhook`]
|
||||||
///
|
///
|
||||||
/// [`SetWebhook`]: crate::requests::SetWebhook
|
/// [`SetWebhook`]: crate::requests::SetWebhook
|
||||||
#[serde(rename = "Bad Request: bad webhook: HTTPS url must be provided for webhook")]
|
#[serde(rename = "Bad Request: bad webhook: Failed to resolve host: Name or service not known")]
|
||||||
WebhookRequireHTTPS,
|
UnknownHost,
|
||||||
|
|
||||||
/// Occurs when bot tries to set webhook to port other than 80, 88, 443 or
|
/// Occurs when bot tries to set webhook to invalid URL.
|
||||||
/// 8443.
|
///
|
||||||
///
|
/// May happen in methods:
|
||||||
/// May happen in methods:
|
/// 1. [`SetWebhook`]
|
||||||
/// 1. [`SetWebhook`]
|
///
|
||||||
///
|
/// [`SetWebhook`]: crate::requests::SetWebhook
|
||||||
/// [`SetWebhook`]: crate::requests::SetWebhook
|
#[serde(rename = "Bad Request: can't parse URL")]
|
||||||
#[serde(rename = "Bad Request: bad webhook: Webhook can be set up only on ports 80, 88, 443 \
|
CantParseUrl,
|
||||||
or 8443")]
|
|
||||||
BadWebhookPort,
|
|
||||||
|
|
||||||
/// Occurs when bot tries to set webhook to unknown host.
|
/// Occurs when bot tries to send message with unfinished entities.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SetWebhook`]
|
/// 1. [`SendMessage`]
|
||||||
///
|
///
|
||||||
/// [`SetWebhook`]: crate::requests::SetWebhook
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
#[serde(rename = "Bad Request: bad webhook: Failed to resolve host: Name or service not known")]
|
#[serde(rename = "Bad Request: can't parse entities")]
|
||||||
UnknownHost,
|
CantParseEntities,
|
||||||
|
|
||||||
/// Occurs when bot tries to set webhook to invalid URL.
|
/// Occurs when bot tries to use getUpdates while webhook is active.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SetWebhook`]
|
/// 1. [`GetUpdates`]
|
||||||
///
|
///
|
||||||
/// [`SetWebhook`]: crate::requests::SetWebhook
|
/// [`GetUpdates`]: crate::requests::GetUpdates
|
||||||
#[serde(rename = "Bad Request: can't parse URL")]
|
#[serde(rename = "can't use getUpdates method while webhook is active")]
|
||||||
CantParseUrl,
|
CantGetUpdates,
|
||||||
|
|
||||||
/// Occurs when bot tries to send message with unfinished entities.
|
/// Occurs when bot tries to do some in group where bot was kicked.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SendMessage`]
|
/// 1. [`SendMessage`]
|
||||||
///
|
///
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
#[serde(rename = "Bad Request: can't parse entities")]
|
#[serde(rename = "Unauthorized: bot was kicked from a chat")]
|
||||||
CantParseEntities,
|
BotKicked,
|
||||||
|
|
||||||
/// Occurs when bot tries to use getUpdates while webhook is active.
|
/// Occurs when bot tries to send message to deactivated user.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`GetUpdates`]
|
/// 1. [`SendMessage`]
|
||||||
///
|
///
|
||||||
/// [`GetUpdates`]: crate::requests::GetUpdates
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
#[serde(rename = "can't use getUpdates method while webhook is active")]
|
#[serde(rename = "Unauthorized: user is deactivated")]
|
||||||
CantGetUpdates,
|
UserDeactivated,
|
||||||
|
|
||||||
/// Occurs when bot tries to do some in group where bot was kicked.
|
/// Occurs when you tries to initiate conversation with a user.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SendMessage`]
|
/// 1. [`SendMessage`]
|
||||||
///
|
///
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
#[serde(rename = "Unauthorized: bot was kicked from a chat")]
|
#[serde(rename = "Unauthorized: bot can't initiate conversation with a user")]
|
||||||
BotKicked,
|
CantInitiateConversation,
|
||||||
|
|
||||||
/// Occurs when bot tries to send message to deactivated user.
|
/// Occurs when you tries to send message to bot.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SendMessage`]
|
/// 1. [`SendMessage`]
|
||||||
///
|
///
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
#[serde(rename = "Unauthorized: user is deactivated")]
|
#[serde(rename = "Unauthorized: bot can't send messages to bots")]
|
||||||
UserDeactivated,
|
CantTalkWithBots,
|
||||||
|
|
||||||
/// Occurs when you tries to initiate conversation with a user.
|
/// Occurs when bot tries to send button with invalid http url.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SendMessage`]
|
/// 1. [`SendMessage`]
|
||||||
///
|
///
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
/// [`SendMessage`]: crate::requests::SendMessage
|
||||||
#[serde(rename = "Unauthorized: bot can't initiate conversation with a user")]
|
#[serde(rename = "Bad Request: wrong HTTP URL")]
|
||||||
CantInitiateConversation,
|
WrongHTTPurl,
|
||||||
|
|
||||||
/// Occurs when you tries to send message to bot.
|
/// Occurs when bot tries GetUpdate before the timeout. Make sure that only
|
||||||
///
|
/// one Updater is running.
|
||||||
/// May happen in methods:
|
///
|
||||||
/// 1. [`SendMessage`]
|
/// May happen in methods:
|
||||||
///
|
/// 1. [`GetUpdates`]
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
///
|
||||||
#[serde(rename = "Unauthorized: bot can't send messages to bots")]
|
/// [`GetUpdates`]: crate::requests::GetUpdates
|
||||||
CantTalkWithBots,
|
#[serde(rename = "Conflict: terminated by other getUpdates request; make sure that only one \
|
||||||
|
bot instance is running")]
|
||||||
|
TerminatedByOtherGetUpdates,
|
||||||
|
|
||||||
/// Occurs when bot tries to send button with invalid http url.
|
/// Occurs when bot tries to get file by invalid file id.
|
||||||
///
|
///
|
||||||
/// May happen in methods:
|
/// May happen in methods:
|
||||||
/// 1. [`SendMessage`]
|
/// 1. [`GetFile`]
|
||||||
///
|
///
|
||||||
/// [`SendMessage`]: crate::requests::SendMessage
|
/// [`GetFile`]: crate::requests::GetFile
|
||||||
#[serde(rename = "Bad Request: wrong HTTP URL")]
|
#[serde(rename = "Bad Request: invalid file id")]
|
||||||
WrongHTTPurl,
|
FileIdInvalid,
|
||||||
|
|
||||||
/// Occurs when bot tries GetUpdate before the timeout. Make sure that only
|
/// Error which is not known to `teloxide`.
|
||||||
/// one Updater is running.
|
///
|
||||||
///
|
/// If you've received this error, please [open an issue] with the
|
||||||
/// May happen in methods:
|
/// description of the error.
|
||||||
/// 1. [`GetUpdates`]
|
///
|
||||||
///
|
/// [open an issue]: https://github.com/teloxide/teloxide/issues/new
|
||||||
/// [`GetUpdates`]: crate::requests::GetUpdates
|
Unknown(String),
|
||||||
#[serde(rename = "Conflict: terminated by other getUpdates request; make sure that only one \
|
|
||||||
bot instance is running")]
|
|
||||||
TerminatedByOtherGetUpdates,
|
|
||||||
|
|
||||||
/// Occurs when bot tries to get file by invalid file id.
|
|
||||||
///
|
|
||||||
/// May happen in methods:
|
|
||||||
/// 1. [`GetFile`]
|
|
||||||
///
|
|
||||||
/// [`GetFile`]: crate::requests::GetFile
|
|
||||||
#[serde(rename = "Bad Request: invalid file id")]
|
|
||||||
FileIdInvalid,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,85 +307,3 @@ macro_rules! impl_payload {
|
||||||
$T
|
$T
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
macro_rules! serde_or_unknown {
|
|
||||||
(
|
|
||||||
#[unknown_mod = $mod_:ident]
|
|
||||||
#[unknown_kind = $Kind:ident]
|
|
||||||
#[unknown_path = $path:literal]
|
|
||||||
$(
|
|
||||||
#[ $($meta:tt)* ]
|
|
||||||
)*
|
|
||||||
$v:vis enum $Name:ident {
|
|
||||||
#[unknown]
|
|
||||||
$(
|
|
||||||
#[ $($unknown_meta:tt)* ]
|
|
||||||
)*
|
|
||||||
$Unknown:ident(String)
|
|
||||||
|
|
||||||
$(
|
|
||||||
,
|
|
||||||
$(
|
|
||||||
#[ $($var_meta:tt)* ]
|
|
||||||
)*
|
|
||||||
$Var:ident
|
|
||||||
)*
|
|
||||||
$(,)?
|
|
||||||
}
|
|
||||||
) => {
|
|
||||||
mod $mod_ {
|
|
||||||
#[allow(unused_imports)]
|
|
||||||
use super::{*, $Name as _};
|
|
||||||
|
|
||||||
$(
|
|
||||||
#[ $($meta)* ]
|
|
||||||
)*
|
|
||||||
$v enum $Name {
|
|
||||||
$(
|
|
||||||
$(
|
|
||||||
#[ $($var_meta)* ]
|
|
||||||
)*
|
|
||||||
$Var,
|
|
||||||
)*
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(::serde::Deserialize)]
|
|
||||||
#[serde(untagged)]
|
|
||||||
$v enum $Kind {
|
|
||||||
Known($Name),
|
|
||||||
Unknown(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ::core::convert::From<$Kind> for super::$Name {
|
|
||||||
fn from(kind: $Kind) -> Self {
|
|
||||||
match kind {
|
|
||||||
$Kind::Unknown(string) => Self::Unknown(string),
|
|
||||||
$Kind::Known(known) => match known {
|
|
||||||
$(
|
|
||||||
$Name::$Var => Self::$Var,
|
|
||||||
)*
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$(
|
|
||||||
#[ $($meta)* ]
|
|
||||||
)*
|
|
||||||
#[serde(from = $path)]
|
|
||||||
$v enum $Name {
|
|
||||||
$(
|
|
||||||
$(
|
|
||||||
#[ $($var_meta)* ]
|
|
||||||
)*
|
|
||||||
$Var,
|
|
||||||
)*
|
|
||||||
$(
|
|
||||||
#[ $($unknown_meta)* ]
|
|
||||||
)*
|
|
||||||
$Unknown(String),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -66,4 +66,14 @@ mod tests {
|
||||||
matches!(val, TelegramResponse::Err { error: ApiError::TerminatedByOtherGetUpdates, .. })
|
matches!(val, TelegramResponse::Err { error: ApiError::TerminatedByOtherGetUpdates, .. })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_unknown() {
|
||||||
|
let s = r#"{"ok":false,"error_code":111,"description":"Unknown description that won't match anything"}"#;
|
||||||
|
let val = serde_json::from_str::<TelegramResponse<Update>>(s).unwrap();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
matches!(val, TelegramResponse::Err { error: ApiError::Unknown(s), .. } if s == "Unknown description that won't match anything")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue