matrix_sdk/sliding_sync/
error.rs

1//! Sliding Sync errors.
2
3use matrix_sdk_common::executor::JoinError;
4use thiserror::Error;
5
6/// Internal representation of errors in Sliding Sync.
7#[derive(Error, Debug)]
8#[non_exhaustive]
9pub enum Error {
10    /// Sliding sync has been configured with a missing version. See
11    /// [`crate::sliding_sync::Version`].
12    #[error("Sliding sync version is missing")]
13    VersionIsMissing,
14
15    /// The response we've received from the server can't be parsed or doesn't
16    /// match up with the current expectations on the client side. A
17    /// `sync`-restart might be required.
18    #[error("The sliding sync response could not be handled: {0}")]
19    BadResponse(String),
20
21    /// A `SlidingSyncListRequestGenerator` has been used without having been
22    /// initialized. It happens when a response is handled before a request has
23    /// been sent. It usually happens when testing.
24    #[error("The sliding sync list `{0}` is handling a response, but its request generator has not been initialized")]
25    RequestGeneratorHasNotBeenInitialized(String),
26
27    /// Ranges have a `start` bound greater than `end`.
28    #[error("Ranges have invalid bounds: `{start}..{end}`")]
29    InvalidRange {
30        /// Start bound.
31        start: u32,
32        /// End bound.
33        end: u32,
34    },
35
36    /// We tried to read the user id of a client but it was missing.
37    #[error("Unauthenticated user in sliding sync")]
38    UnauthenticatedUser,
39
40    /// The internal channel of `SlidingSync` seems to be broken.
41    #[error("SlidingSync's internal channel is broken")]
42    InternalChannelIsBroken,
43
44    /// The name of the Sliding Sync instance is too long.
45    #[error("The Sliding Sync instance's identifier must be less than 16 chars long")]
46    InvalidSlidingSyncIdentifier,
47
48    /// A task failed to execute to completion.
49    #[error("A task failed to execute to completion; task description: {task_description}, error: {error}")]
50    JoinError {
51        /// Task description.
52        task_description: String,
53        /// The original `JoinError`.
54        error: JoinError,
55    },
56
57    /// No Olm machine.
58    #[cfg(feature = "e2e-encryption")]
59    #[error("The Olm machine is missing")]
60    NoOlmMachine,
61
62    /// An error occurred during a E2EE operation.
63    #[cfg(feature = "e2e-encryption")]
64    #[error(transparent)]
65    CryptoStoreError(#[from] matrix_sdk_base::crypto::CryptoStoreError),
66}