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(
25        "The sliding sync list `{0}` is handling a response, \
26         but its request generator has not been initialized"
27    )]
28    RequestGeneratorHasNotBeenInitialized(String),
29
30    /// Ranges have a `start` bound greater than `end`.
31    #[error("Ranges have invalid bounds: `{start}..{end}`")]
32    InvalidRange {
33        /// Start bound.
34        start: u32,
35        /// End bound.
36        end: u32,
37    },
38
39    /// We tried to read the user id of a client but it was missing.
40    #[error("Unauthenticated user in sliding sync")]
41    UnauthenticatedUser,
42
43    /// The internal channel of `SlidingSync` seems to be broken.
44    #[error("SlidingSync's internal channel is broken")]
45    InternalChannelIsBroken,
46
47    /// The name of the Sliding Sync instance is too long.
48    #[error("The Sliding Sync instance's identifier must be less than 16 chars long")]
49    InvalidSlidingSyncIdentifier,
50
51    /// A task failed to execute to completion.
52    #[error(
53        "A task failed to execute to completion; \
54         task description: {task_description}, error: {error}"
55    )]
56    JoinError {
57        /// Task description.
58        task_description: String,
59        /// The original `JoinError`.
60        error: JoinError,
61    },
62
63    /// No Olm machine.
64    #[cfg(feature = "e2e-encryption")]
65    #[error("The Olm machine is missing")]
66    NoOlmMachine,
67
68    /// An error occurred during a E2EE operation.
69    #[cfg(feature = "e2e-encryption")]
70    #[error(transparent)]
71    CryptoStoreError(#[from] matrix_sdk_base::crypto::CryptoStoreError),
72}