use matrix_sdk_common::cross_process_lock::CrossProcessLockError;
#[cfg(feature = "e2e-encryption")]
use matrix_sdk_crypto::{CryptoStoreError, MegolmError, OlmError};
use thiserror::Error;
use crate::event_cache::store::EventCacheStoreError;
pub type Result<T, E = Error> = std::result::Result<T, E>;
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum Error {
#[cfg(feature = "e2e-encryption")]
#[error("The olm machine has already been initialized")]
BadCryptoStoreState,
#[cfg(feature = "e2e-encryption")]
#[error("The room where a group session should be shared is not encrypted")]
EncryptionNotEnabled,
#[error(transparent)]
StateStore(#[from] crate::store::StoreError),
#[error(transparent)]
EventCacheStore(#[from] EventCacheStoreError),
#[error(transparent)]
EventCacheLock(#[from] CrossProcessLockError),
#[cfg(feature = "e2e-encryption")]
#[error(transparent)]
CryptoStore(#[from] CryptoStoreError),
#[cfg(feature = "e2e-encryption")]
#[error(transparent)]
OlmError(#[from] OlmError),
#[cfg(feature = "e2e-encryption")]
#[error(transparent)]
MegolmError(#[from] MegolmError),
#[error("receive_all_members function was called with invalid parameters")]
InvalidReceiveMembersParameters,
#[error("Local cache doesn't contain all necessary data to perform the action.")]
InsufficientData,
#[error(transparent)]
DeserializationError(#[from] serde_json::error::Error),
}