mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-16 20:49:05 -04:00
feat(crypto): Add a store error variant for breaking database format changes
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user