|
14 | 14 |
|
15 | 15 | use indexed_db_futures::{prelude::IdbTransaction, IdbQuerySource};
|
16 | 16 | use matrix_sdk_base::{
|
17 |
| - event_cache::{Event as RawEvent, Gap as RawGap}, |
| 17 | + event_cache::{store::EventCacheStoreError, Event as RawEvent, Gap as RawGap}, |
18 | 18 | linked_chunk::{ChunkContent, ChunkIdentifier, RawChunk},
|
19 | 19 | };
|
20 | 20 | use ruma::{events::relation::RelationType, OwnedEventId, RoomId};
|
21 |
| -use serde::{de::DeserializeOwned, Serialize}; |
| 21 | +use serde::{ |
| 22 | + de::{DeserializeOwned, Error}, |
| 23 | + Serialize, |
| 24 | +}; |
22 | 25 | use thiserror::Error;
|
23 | 26 | use web_sys::IdbCursorDirection;
|
24 | 27 |
|
@@ -55,9 +58,19 @@ impl From<web_sys::DomException> for IndexeddbEventCacheStoreTransactionError {
|
55 | 58 |
|
56 | 59 | impl From<serde_wasm_bindgen::Error> for IndexeddbEventCacheStoreTransactionError {
|
57 | 60 | fn from(e: serde_wasm_bindgen::Error) -> Self {
|
58 |
| - Self::Serialization(Box::new(<serde_json::Error as serde::de::Error>::custom( |
59 |
| - e.to_string(), |
60 |
| - ))) |
| 61 | + Self::Serialization(Box::new(serde_json::Error::custom(e.to_string()))) |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +impl From<IndexeddbEventCacheStoreTransactionError> for EventCacheStoreError { |
| 66 | + fn from(value: IndexeddbEventCacheStoreTransactionError) -> Self { |
| 67 | + use IndexeddbEventCacheStoreTransactionError::*; |
| 68 | + |
| 69 | + match value { |
| 70 | + DomException { .. } => Self::InvalidData { details: value.to_string() }, |
| 71 | + Serialization(e) => Self::Serialization(serde_json::Error::custom(e.to_string())), |
| 72 | + ItemIsNotUnique | ItemNotFound => Self::InvalidData { details: value.to_string() }, |
| 73 | + } |
61 | 74 | }
|
62 | 75 | }
|
63 | 76 |
|
|
0 commit comments