pub struct EndpointError {
pub message: String,
pub kind: String,
pub status: u16,
pub parameters: Option<JsValue>,
}Expand description
Failure reported by a Telegram Serverless endpoint call.
Mirrors the ServerlessError object the JavaScript bridge passes to the
failure callback of Telegram.WebApp.Serverless.call. Client-side
failures (missing bridge, payload that cannot be (de)serialized) keep
Self::kind empty and Self::status at 0.
Fields§
§message: StringHuman-readable description of the failure.
kind: StringMachine-readable error category reported by the endpoint, such as
"ENDPOINT_ERROR" or "UNAUTHORIZED"; empty when Telegram did not
classify the failure.
status: u16HTTP status code of the endpoint response, or 0 when the request
could not be completed.
parameters: Option<JsValue>Additional structured data the endpoint passed along with its error.
Implementations§
Source§impl EndpointError
impl EndpointError
Sourcepub fn from_js_value(value: &JsValue) -> Self
pub fn from_js_value(value: &JsValue) -> Self
Decodes a rejection value produced by the JavaScript bridge.
Values that are not ServerlessError objects — for example the plain
Error thrown when the app was not opened from Telegram — are mapped
to an error with an empty Self::kind and a Self::status of 0.
Sourcepub fn hint(&self) -> &'static str
pub fn hint(&self) -> &'static str
Returns an actionable hint describing how to recover from this error.
The hint is keyed on the platform error category stored in
Self::kind (see the Serverless section of the Bot API
documentation) and falls back to the HTTP status class in
Self::status when the failure was not classified.
§Examples
use telegram_webapp_sdk::api::serverless::EndpointError;
let error = EndpointError {
message: "init data is invalid".to_string(),
kind: "UNAUTHORIZED".to_string(),
status: 401,
parameters: None
};
assert!(error.hint().contains("initData"));Trait Implementations§
Source§impl Clone for EndpointError
impl Clone for EndpointError
Source§impl Debug for EndpointError
impl Debug for EndpointError
Source§impl Display for EndpointError
impl Display for EndpointError
Source§impl Error for EndpointError
impl Error for EndpointError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<EndpointError> for JsValue
impl From<EndpointError> for JsValue
Source§fn from(error: EndpointError) -> Self
fn from(error: EndpointError) -> Self
Source§impl PartialEq for EndpointError
impl PartialEq for EndpointError
impl StructuralPartialEq for EndpointError
Auto Trait Implementations§
impl Forget for EndpointError
impl Freeze for EndpointError
impl Move for EndpointError
impl RefUnwindSafe for EndpointError
impl Send for EndpointError
impl Sync for EndpointError
impl Unpin for EndpointError
impl UnsafeUnpin for EndpointError
impl UnwindSafe for EndpointError
Blanket Implementations§
impl<Token, Builder, How> AllPropsFor<Builder, How> for Tokenwhere
Builder: Buildable<Token>,
<Builder as Buildable<Token>>::WrappedToken: HasAllProps<<Builder as Buildable<Token>>::Output, How>,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> HasAllProps<(), T> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self to a value of a Properties struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self to a value of a Properties struct.