Skip to content

Commit

Permalink
feat(crypto): Add a store error variant for breaking database format …
Browse files Browse the repository at this point in the history
…changes
  • Loading branch information
poljar committed Mar 25, 2022
1 parent 0ce74b9 commit 2bacbf1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 8 additions & 0 deletions crates/matrix-sdk-crypto/src/store/mod.rs
Expand Up @@ -597,6 +597,14 @@ pub enum CryptoStoreError {
/// The store failed to (de)serialize a data type.
#[error(transparent)]
Serialization(#[from] SerdeError),

/// The database format has changed in a backwards incompatible way.
#[error(
"The database format changed in an incompatible way, current \
version: {0}, latest version: {1}"
)]
UnsupportedDatabaseVersion(usize, usize),

/// A problem with the underlying database backend
#[error(transparent)]
Backend(#[from] anyhow::Error),
Expand Down
9 changes: 4 additions & 5 deletions crates/matrix-sdk-sled/src/cryptostore.rs
Expand Up @@ -486,11 +486,10 @@ impl SledStore {
}

if version <= 3 {
return Err(anyhow!(
"Unsupported database version, the database \
format changed in a backwards incompatible way"
)
.into());
return Err(CryptoStoreError::UnsupportedDatabaseVersion(
version.into(),
DATABASE_VERSION.into(),
));
}

self.inner
Expand Down

0 comments on commit 2bacbf1

Please sign in to comment.