matrix_sdk_indexeddb/
error.rs1#[cfg(feature = "event-cache-store")]
16use matrix_sdk_base::event_cache::store::EventCacheStoreError;
17#[cfg(feature = "media-store")]
18use matrix_sdk_base::media::store::MediaStoreError;
19#[cfg(feature = "state-store")]
20use matrix_sdk_base::StoreError;
21#[cfg(any(feature = "event-cache-store", feature = "media-store"))]
22use matrix_sdk_base::{SendOutsideWasm, SyncOutsideWasm};
23#[cfg(feature = "e2e-encryption")]
24use matrix_sdk_crypto::CryptoStoreError;
25use thiserror::Error;
26
27#[cfg(any(feature = "event-cache-store", feature = "media-store"))]
31pub trait AsyncErrorDeps: std::error::Error + SendOutsideWasm + SyncOutsideWasm + 'static {}
32
33#[cfg(any(feature = "event-cache-store", feature = "media-store"))]
34impl<T> AsyncErrorDeps for T where T: std::error::Error + SendOutsideWasm + SyncOutsideWasm + 'static
35{}
36
37#[derive(Debug, Error)]
42#[error("{0}")]
43pub struct GenericError(String);
44
45impl<S: AsRef<str>> From<S> for GenericError {
46 fn from(value: S) -> Self {
47 Self(value.as_ref().to_owned())
48 }
49}
50
51#[cfg(feature = "e2e-encryption")]
52impl From<GenericError> for CryptoStoreError {
53 fn from(value: GenericError) -> Self {
54 Self::backend(value)
55 }
56}
57
58#[cfg(feature = "event-cache-store")]
59impl From<GenericError> for EventCacheStoreError {
60 fn from(value: GenericError) -> Self {
61 Self::backend(value)
62 }
63}
64
65#[cfg(feature = "media-store")]
66impl From<GenericError> for MediaStoreError {
67 fn from(value: GenericError) -> Self {
68 Self::backend(value)
69 }
70}
71
72#[cfg(feature = "state-store")]
73impl From<GenericError> for StoreError {
74 fn from(value: GenericError) -> Self {
75 Self::backend(value)
76 }
77}