Enum teloxide_core::errors::ApiError

source ·
#[non_exhaustive]
pub enum ApiError {
Show 67 variants BotBlocked, InvalidToken, MessageNotModified, MessageIdInvalid, MessageToForwardNotFound, MessageToDeleteNotFound, MessageToCopyNotFound, MessageTextIsEmpty, MessageCantBeEdited, MessageCantBeDeleted, MessageToEditNotFound, MessageToReplyNotFound, MessageIdentifierNotSpecified, MessageIsTooLong, EditedMessageIsTooLong, TooMuchMessages, TooMuchInlineQueryResults, PollHasAlreadyClosed, PollMustHaveMoreOptions, PollCantHaveMoreOptions, PollOptionsMustBeNonEmpty, PollQuestionMustBeNonEmpty, PollOptionsLengthTooLong, PollQuestionLengthTooLong, MessageWithPollNotFound, MessageIsNotAPoll, ChatNotFound, UserNotFound, ChatDescriptionIsNotModified, InvalidQueryId, ButtonUrlInvalid, ButtonDataInvalid, TextButtonsAreUnallowed, WrongFileId, WrongFileIdOrUrl, FailedToGetUrlContent, GroupDeactivated, ImageProcessFailed, PhotoAsInputFileRequired, InvalidStickersSet, StickerSetNameOccupied, StickerSetOwnerIsBot, InvalidStickerName, NotEnoughRightsToPinMessage, NotEnoughRightsToManagePins, NotEnoughRightsToChangeChatPermissions, MethodNotAvailableInPrivateChats, CantDemoteChatCreator, CantRestrictSelf, NotEnoughRightsToRestrict, NotEnoughRightsToPostMessages, WebhookRequireHttps, BadWebhookPort, UnknownHost, CantParseUrl, CantParseEntities(String), CantGetUpdates, BotKicked, BotKickedFromSupergroup, UserDeactivated, CantInitiateConversation, CantTalkWithBots, WrongHttpUrl, TerminatedByOtherGetUpdates, FileIdInvalid, RequestEntityTooLarge, Unknown(String),
}
Expand description

A kind of an API error.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

BotBlocked

Occurs when the bot tries to send message to user who blocked the bot.

§

InvalidToken

Occurs when the bot token is invalid.

§

MessageNotModified

Occurs when bot tries to modify a message without modification content.

May happen in methods:

  1. EditMessageText
§

MessageIdInvalid

Occurs when bot tries to forward or delete a message which was deleted.

May happen in methods:

  1. ForwardMessage
  2. DeleteMessage
§

MessageToForwardNotFound

Occurs when bot tries to forward a message which does not exists.

May happen in methods:

  1. ForwardMessage
§

MessageToDeleteNotFound

Occurs when bot tries to delete a message which does not exists.

May happen in methods:

  1. DeleteMessage
§

MessageToCopyNotFound

Occurs when bot tries to copy a message which does not exists. May happen in methods:

  1. CopyMessage
§

MessageTextIsEmpty

Occurs when bot tries to send a text message without text.

May happen in methods:

  1. SendMessage
§

MessageCantBeEdited

Occurs when bot tries to edit a message after long time.

May happen in methods:

  1. EditMessageText
§

MessageCantBeDeleted

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. DeleteMessage
§

MessageToEditNotFound

Occurs when bot tries to edit a message which does not exists.

May happen in methods:

  1. EditMessageText
§

MessageToReplyNotFound

Occurs when bot tries to reply to a message which does not exists.

May happen in methods:

  1. SendMessage
§

MessageIdentifierNotSpecified

Occurs when bot tries to

§

MessageIsTooLong

Occurs when bot tries to send a message with text size greater then 4096 symbols.

May happen in methods:

  1. SendMessage
§

EditedMessageIsTooLong

Occurs when bot tries to edit a message with text size greater then 4096 symbols.

May happen in methods:

  1. EditMessageText
  2. EditMessageTextInline
  3. EditMessageCaption
  4. EditMessageCaptionInline
§

TooMuchMessages

Occurs when bot tries to send media group with more than 10 items.

May happen in methods:

  1. SendMediaGroup
§

TooMuchInlineQueryResults

Occurs when bot tries to answer an inline query with more than 50 results.

Consider using offsets to paginate results.

May happen in methods:

  1. AnswerInlineQuery
§

PollHasAlreadyClosed

Occurs when bot tries to stop poll that has already been stopped.

May happen in methods:

  1. SendPoll
§

PollMustHaveMoreOptions

Occurs when bot tries to send poll with less than 2 options.

May happen in methods:

  1. SendPoll
§

PollCantHaveMoreOptions

Occurs when bot tries to send poll with more than 10 options.

May happen in methods:

  1. SendPoll
§

PollOptionsMustBeNonEmpty

Occurs when bot tries to send poll with empty option (without text).

May happen in methods:

  1. SendPoll
§

PollQuestionMustBeNonEmpty

Occurs when bot tries to send poll with empty question (without text).

May happen in methods:

  1. SendPoll
§

PollOptionsLengthTooLong

Occurs when bot tries to send poll with total size of options more than 100 symbols.

May happen in methods:

  1. SendPoll
§

PollQuestionLengthTooLong

Occurs when bot tries to send poll with question size more than 255 symbols.

May happen in methods:

  1. SendPoll
§

MessageWithPollNotFound

Occurs when bot tries to stop poll with message without poll.

May happen in methods:

  1. StopPoll
§

MessageIsNotAPoll

Occurs when bot tries to stop poll with message without poll.

May happen in methods:

  1. StopPoll
§

ChatNotFound

Occurs when bot tries to send a message to chat in which it is not a member.

May happen in methods:

  1. SendMessage
§

UserNotFound

Occurs when bot tries to send method with unknown user_id.

May happen in methods:

  1. getUserProfilePhotos
§

ChatDescriptionIsNotModified

Occurs when bot tries to send SetChatDescription with same text as in the current description.

May happen in methods:

  1. SetChatDescription
§

InvalidQueryId

Occurs when bot tries to answer to query after timeout expire.

May happen in methods:

  1. AnswerCallbackQuery
§

ButtonUrlInvalid

Occurs when bot tries to send InlineKeyboardMarkup with invalid button url.

May happen in methods:

  1. SendMessage
§

ButtonDataInvalid

Occurs when bot tries to send button with data size more than 64 bytes.

May happen in methods:

  1. SendMessage
§

TextButtonsAreUnallowed

Occurs when bot tries to send button with data size == 0.

May happen in methods:

  1. SendMessage
§

WrongFileId

Occurs when bot tries to get file by wrong file id.

May happen in methods:

  1. GetFile
§

WrongFileIdOrUrl

Occurs when bot tries to send files with wrong file identifier or HTTP url

§

FailedToGetUrlContent

Occurs when When sending files with an url to a site that doesn’t respond.

§

GroupDeactivated

Occurs when bot tries to do some with group which was deactivated.

§

ImageProcessFailed

Occurs when image processing fails on telegram’s side.

This is likely caused by an incorrectly encoded image, make sure that the image is correctly encoded in a format telegram accepts.

§

PhotoAsInputFileRequired

Occurs when bot tries to set chat photo from file ID

May happen in methods:

  1. SetChatPhoto
§

InvalidStickersSet

Occurs when bot tries to add sticker to stickerset by invalid name.

May happen in methods:

  1. AddStickerToSet
§

StickerSetNameOccupied

Occurs when bot tries to create a sticker set with a name that is already used by another sticker set.

May happen in methods:

  1. CreateNewStickerSet
§

StickerSetOwnerIsBot

Occurs when bot tries to create a sticker set with user id of a bot.

May happen in methods:

  1. CreateNewStickerSet
§

InvalidStickerName

Occurs when bot tries to create a sticker set with invalid name.

From documentation of CreateNewStickerSet:

Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can’t contain consecutive underscores and must end in “_by_<bot_username>”. <bot_username> is case insensitive. 1-64 characters.

May happen in methods:

  1. CreateNewStickerSet
§

NotEnoughRightsToPinMessage

Occurs when bot tries to pin a message without rights to pin in this chat.

May happen in methods:

  1. PinChatMessage
§

NotEnoughRightsToManagePins

Occurs when bot tries to pin or unpin a message without rights to pin in this chat.

May happen in methods:

  1. PinChatMessage
  2. UnpinChatMessage
§

NotEnoughRightsToChangeChatPermissions

Occurs when bot tries change default chat permissions without “Ban Users” permission in this chat.

May happen in methods:

  1. SetChatPermissions
§

MethodNotAvailableInPrivateChats

Occurs when bot tries to use method in group which is allowed only in a supergroup or channel.

§

CantDemoteChatCreator

Occurs when bot tries to demote chat creator.

May happen in methods:

  1. PromoteChatMember
§

CantRestrictSelf

Occurs when bot tries to restrict self in group chats.

May happen in methods:

  1. RestrictChatMember
§

NotEnoughRightsToRestrict

Occurs when bot tries to restrict chat member without rights to restrict in this chat.

May happen in methods:

  1. RestrictChatMember
§

NotEnoughRightsToPostMessages

Occurs when bot tries to post a message in a channel without “Post Messages” admin right.

§

WebhookRequireHttps

Occurs when bot tries set webhook to protocol other than HTTPS.

May happen in methods:

  1. SetWebhook
§

BadWebhookPort

Occurs when bot tries to set webhook to port other than 80, 88, 443 or 8443.

May happen in methods:

  1. SetWebhook
§

UnknownHost

Occurs when bot tries to set webhook to unknown host.

May happen in methods:

  1. SetWebhook
§

CantParseUrl

Occurs when bot tries to set webhook to invalid URL.

May happen in methods:

  1. SetWebhook
§

CantParseEntities(String)

Occurs when bot tries to send message with unfinished entities.

May happen in methods:

  1. SendMessage
§

CantGetUpdates

Occurs when bot tries to use getUpdates while webhook is active.

May happen in methods:

  1. GetUpdates
§

BotKicked

Occurs when bot tries to do some in group where bot was kicked.

May happen in methods:

  1. SendMessage
§

BotKickedFromSupergroup

Occurs when bot tries to do something in a supergroup the bot was kicked from.

May happen in methods:

  1. SendMessage
§

UserDeactivated

Occurs when bot tries to send a message to a deactivated user (i.e. a user that was banned by telegram).

May happen in methods:

  1. SendMessage
§

CantInitiateConversation

Occurs when you tries to initiate conversation with a user.

May happen in methods:

  1. SendMessage
§

CantTalkWithBots

Occurs when you tries to send message to bot.

May happen in methods:

  1. SendMessage
§

WrongHttpUrl

Occurs when bot tries to send button with invalid http url.

May happen in methods:

  1. SendMessage
§

TerminatedByOtherGetUpdates

Occurs when multiple GetUpdates calls happen at the same time.

This can happen if

  1. You are running multiple bot instances
  2. You are running multiple update consumers (like Dispatcher or repl)
  3. You are calling GetUpdates yourself and the second call is done before the first one finishes

May happen in methods:

  1. GetUpdates
§

FileIdInvalid

Occurs when bot tries to get file by invalid file id.

May happen in methods:

  1. GetFile
§

RequestEntityTooLarge

Occurs when bot tries to upload a file which is larger than 50 MB using multipart/form-data.

May happen in methods:

  1. SendVideo
  2. SendDocument
§

Unknown(String)

Error which is not known to teloxide.

If you’ve received this error, please open an issue with the description of the error.

Trait Implementations§

source§

impl Clone for ApiError

source§

fn clone(&self) -> ApiError

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ApiError

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for ApiError

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for ApiError

source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Error for ApiError

1.30.0 · source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
source§

impl From<ApiError> for RequestError

source§

fn from(source: ApiError) -> Self

Converts to this type from the input type.
source§

impl Hash for ApiError

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for ApiError

source§

fn eq(&self, other: &ApiError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for ApiError

source§

impl StructuralPartialEq for ApiError

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> Erasable for T

source§

unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>

Unerase this erased pointer. Read more
source§

const ACK_1_1_0: bool = true

Available on non-enforce_1_1_0_semantics only.
Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more
source§

fn erase(this: NonNull<Self>) -> NonNull<Erased>

Turn this erasable pointer into an erased pointer. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,