1//! Sliding Sync errors.
23use matrix_sdk_common::executor::JoinError;
4use thiserror::Error;
56/// 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")]
13VersionIsMissing,
1415/// 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}")]
19BadResponse(String),
2021/// 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")]
25RequestGeneratorHasNotBeenInitialized(String),
2627/// Ranges have a `start` bound greater than `end`.
28#[error("Ranges have invalid bounds: `{start}..{end}`")]
29InvalidRange {
30/// Start bound.
31start: u32,
32/// End bound.
33end: u32,
34 },
3536/// We tried to read the user id of a client but it was missing.
37#[error("Unauthenticated user in sliding sync")]
38UnauthenticatedUser,
3940/// The internal channel of `SlidingSync` seems to be broken.
41#[error("SlidingSync's internal channel is broken")]
42InternalChannelIsBroken,
4344/// 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")]
46InvalidSlidingSyncIdentifier,
4748/// A task failed to execute to completion.
49#[error("A task failed to execute to completion; task description: {task_description}, error: {error}")]
50JoinError {
51/// Task description.
52task_description: String,
53/// The original `JoinError`.
54error: JoinError,
55 },
5657/// No Olm machine.
58#[cfg(feature = "e2e-encryption")]
59 #[error("The Olm machine is missing")]
60NoOlmMachine,
6162/// An error occurred during a E2EE operation.
63#[cfg(feature = "e2e-encryption")]
64 #[error(transparent)]
65CryptoStoreError(#[from] matrix_sdk_base::crypto::CryptoStoreError),
66}