pub enum Error {
Api {
error_code: u16,
description: String,
migrate_to_chat_id: Option<i64>,
retry_after: Option<u32>,
},
Http(Error),
Serialization(Error),
Decode(String),
RateLimit {
retry_after: u32,
},
InvalidToken,
MissingParam(&'static str),
}Expand description
Errors that can occur when interacting with the Telegram Bot API.
Variants§
Api
The Telegram API returned ok: false.
Fields
Http(Error)
HTTP transport or network error.
Serialization(Error)
Failed to serialise the request body.
Decode(String)
The response body could not be decoded.
RateLimit
Rate limit hit — caller should wait retry_after seconds before retrying.
InvalidToken
The provided token format is invalid.
MissingParam(&'static str)
A required parameter was missing.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_rate_limit(&self) -> bool
pub fn is_rate_limit(&self) -> bool
Returns true if this is a flood-control error (429).
Sourcepub fn retry_after(&self) -> Option<u32>
pub fn retry_after(&self) -> Option<u32>
Extracts the retry_after value if available.
Sourcepub fn is_blocked(&self) -> bool
pub fn is_blocked(&self) -> bool
Returns true if the bot is blocked by the user.
Sourcepub fn is_chat_not_found(&self) -> bool
pub fn is_chat_not_found(&self) -> bool
Returns true if the chat was not found.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more