1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::util::Shape;
use serde_json::Error as SerdeJsonError;
#[derive(thiserror::Error, Debug)]
pub enum Error {
// #[error("Dimension index {dim} exceeds the maximum allowed shape dimensions (5x10) for shape {shape:?}")]
// DimOutOfRange { shape: Shape, dim: i32 },
#[error("Expected status success (1) but got uknown status {status}")]
EventAnswerUnkownStatus { status: i8 },
#[error("Expected some content but got nothing in {from}")]
NoContent { from: &'static str },
#[error("Serde JSON error: {0}")]
SerdeJson(#[from] SerdeJsonError),
#[error("Reqwest error: {0}")]
Reqwest(#[from] reqwest::Error),
#[error("Dimension index {dim} exceeds the maximum allowed shape dimensions (5x10) for shape {shape:?}")]
DimOutOfRange { shape: Shape, dim: i32 },
/// The event history has become outdated or has been partially lost. This can occur if the client fails to
/// poll the server in a timely manner, causing a gap in the event sequence. The client should continue polling
/// with the new `ts` value provided. This is not a critical error but indicates that some events might have been missed.
#[error("LongPoll history is outdated or partially lost. To continue receiving updates, use the new 'ts' key provided: {new_ts}.")]
EventsOutdated { new_ts: String },
/// The session key used for the Long Poll connection has expired. This requires obtaining a new session key by
/// calling the `groups.getLongPollServer` method again. Expired keys are common and expected to happen from time
/// to time; they simply indicate that the connection to the Long Poll server needs to be refreshed.
#[error("The LongPoll session key has expired. Obtain a new key by calling 'groups.getLongPollServer' again.")]
KeyExpired,
/// All session information has been lost, necessitating the initiation of a new Long Poll session. This error
/// typically indicates that the server and key information are no longer valid, possibly due to a significant
/// lapse in polling or server-side changes. Start a new session by re-fetching the server, key, and 'ts' values.
#[error("The LongPoll session's information is lost. Start a new session by re-fetching the server, key, and 'ts' values.")]
InformationLost,
}
pub type Result<T> = std::result::Result<T, Error>;