File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed
crates/matrix-sdk-indexeddb/src/event_cache_store Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ use web_sys::DomException;
20
20
21
21
use crate :: {
22
22
event_cache_store:: {
23
- migrations :: open_and_upgrade_db , serializer :: IndexeddbEventCacheStoreSerializer ,
24
- IndexeddbEventCacheStore ,
23
+ error :: IndexeddbEventCacheStoreError , migrations :: open_and_upgrade_db ,
24
+ serializer :: IndexeddbEventCacheStoreSerializer , IndexeddbEventCacheStore ,
25
25
} ,
26
26
serializer:: IndexeddbSerializer ,
27
27
} ;
@@ -64,7 +64,7 @@ impl IndexeddbEventCacheStoreBuilder {
64
64
/// Opens the IndexedDB database with the provided name. If successfully
65
65
/// opened, builds the [`IndexeddbEventCacheStore`] with that database
66
66
/// and the provided store cipher.
67
- pub async fn build ( self ) -> Result < IndexeddbEventCacheStore , DomException > {
67
+ pub async fn build ( self ) -> Result < IndexeddbEventCacheStore , IndexeddbEventCacheStoreError > {
68
68
Ok ( IndexeddbEventCacheStore {
69
69
inner : open_and_upgrade_db ( & self . database_name ) . await ?,
70
70
serializer : IndexeddbEventCacheStoreSerializer :: new ( IndexeddbSerializer :: new (
Original file line number Diff line number Diff line change 13
13
// limitations under the License
14
14
15
15
use matrix_sdk_base:: { SendOutsideWasm , SyncOutsideWasm } ;
16
+ use thiserror:: Error ;
16
17
17
18
/// A trait that combines the necessary traits needed for asynchronous runtimes,
18
19
/// but excludes them when running in a web environment - i.e., when
@@ -21,3 +22,19 @@ pub trait AsyncErrorDeps: std::error::Error + SendOutsideWasm + SyncOutsideWasm
21
22
22
23
impl < T > AsyncErrorDeps for T where T : std:: error:: Error + SendOutsideWasm + SyncOutsideWasm + ' static
23
24
{ }
25
+
26
+ #[ derive( Debug , Error ) ]
27
+ pub enum IndexeddbEventCacheStoreError {
28
+ #[ error( "DomException {name} ({code}): {message}" ) ]
29
+ DomException { name : String , message : String , code : u16 } ,
30
+ }
31
+
32
+ impl From < web_sys:: DomException > for IndexeddbEventCacheStoreError {
33
+ fn from ( value : web_sys:: DomException ) -> IndexeddbEventCacheStoreError {
34
+ IndexeddbEventCacheStoreError :: DomException {
35
+ name : value. name ( ) ,
36
+ message : value. message ( ) ,
37
+ code : value. code ( ) ,
38
+ }
39
+ }
40
+ }
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ mod transaction;
28
28
mod types;
29
29
30
30
pub use builder:: IndexeddbEventCacheStoreBuilder ;
31
+ pub use error:: IndexeddbEventCacheStoreError ;
31
32
32
33
/// A type for providing an IndexedDB implementation of [`EventCacheStore`][1].
33
34
/// This is meant to be used as a backend to [`EventCacheStore`][1] in browser
You can’t perform that action at this time.
0 commit comments