InvocationError

Enum InvocationError 

Source
pub enum InvocationError {
    Rpc(RpcError),
    Io(Error),
    Deserialize(DeserializeError),
    Transport(Error),
    Dropped,
    InvalidDc,
    Authentication(Error),
}
Expand description

This error occurs when a Remote Procedure call was unsuccessful.

Variants§

§

Rpc(RpcError)

The request invocation failed because it was invalid or the server could not process it successfully. If the server is suffering from temporary issues, the request may be retried after some time.

§

Io(Error)

Standard I/O error when reading the response.

Telegram may kill the connection at any moment, but it is generally valid to retry the request at least once immediately, which will be done through a new connection.

§

Deserialize(DeserializeError)

Error propagated from attempting to deserialize an invalid tl::Deserializable.

This occurs somewhat frequently when misusing a single session more than once at a time. Otherwise it might happen on bleeding-edge layers that have not had time to settle yet.

§

Transport(Error)

Error propagated from the underlying transport.

The most common variant is transport::Error::BadStatus, which can occur when there’s no valid Authorization Key (404) or too many connections have been made (429).

§

Dropped

The request was cancelled or dropped, and the results won’t arrive. This may mean that the crate::SenderPoolRunner is no longer running.

§

InvalidDc

The request was invoked in a datacenter that does not exist or is not known by the session.

§

Authentication(Error)

The request caused the sender to connect to a new datacenter to be performed, but the Authorization Key generation process failed.

Implementations§

Source§

impl InvocationError

Source

pub fn is(&self, rpc_error: &str) -> bool

Matches on the name of the RPC error (case-sensitive).

Useful in match arm guards. A single trailing or leading asterisk ('*') is allowed, and will instead check if the error name starts (or ends with) the input parameter.

If the error is not a RPC error, returns false.

§Examples
match request_result {
    Err(err) if err.is("SESSION_PASSWORD_NEEDED") => panic!(),
    Err(err) if err.is("PHONE_CODE_*") => {},
    _ => panic!()
}

Trait Implementations§

Source§

impl Debug for InvocationError

Source§

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

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

impl Display for InvocationError

Source§

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

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

impl Error for InvocationError

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<DeserializeError> for InvocationError

Source§

fn from(error: DeserializeError) -> InvocationError

Converts to this type from the input type.
Source§

impl From<Error> for InvocationError

Source§

fn from(error: Error) -> InvocationError

Converts to this type from the input type.
Source§

impl From<Error> for InvocationError

Source§

fn from(error: Error) -> InvocationError

Converts to this type from the input type.
Source§

impl From<Error> for InvocationError

Source§

fn from(error: Error) -> InvocationError

Converts to this type from the input type.
Source§

impl From<Error> for InvocationError

Source§

fn from(error: Error) -> InvocationError

Converts to this type from the input type.
Source§

impl From<ReadError> for InvocationError

Source§

fn from(error: ReadError) -> InvocationError

Converts to this type from the input type.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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.