diff options
Diffstat (limited to 'crates/tor-dirmgr/src/err.rs')
| -rw-r--r-- | crates/tor-dirmgr/src/err.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/tor-dirmgr/src/err.rs b/crates/tor-dirmgr/src/err.rs index 2a2f55079..20a533559 100644 --- a/crates/tor-dirmgr/src/err.rs +++ b/crates/tor-dirmgr/src/err.rs @@ -30,6 +30,9 @@ pub enum Error { /// rusqlite gave us an error. #[error("Error from sqlite database")] SqliteError(#[source] Arc<rusqlite::Error>), + /// Error while creating a read-only store. + #[error("Failed to create read-only store")] + ReadOnlyStorage(#[from] ReadOnlyStorageError), /// A schema version that says we can't read it. #[error("Unrecognized data storage schema v{schema}. (We support v{supported})")] UnrecognizedSchema { @@ -232,6 +235,7 @@ impl Error { | Error::CachePermissions(_) | Error::CacheAccess(_) | Error::SqliteError(_) + | Error::ReadOnlyStorage(_) | Error::UnrecognizedSchema { .. } | Error::DirectoryNotPresent | Error::ManagerDropped @@ -302,6 +306,7 @@ impl Error { | Error::OfflineMode | Error::CacheCorruption(_) | Error::SqliteError(_) + | Error::ReadOnlyStorage(_) | Error::UnrecognizedSchema { .. } | Error::ManagerDropped | Error::LockFile { .. } @@ -345,6 +350,7 @@ impl HasKind for Error { E::CachePermissions(e) => e.cache_error_kind(), E::CacheAccess(e) => e.cache_error_kind(), E::SqliteError(e) => sqlite_error_kind(e), + E::ReadOnlyStorage(_) => EK::LocalResourceAlreadyInUse, E::UnrecognizedSchema { .. } => EK::CacheCorrupted, E::DirectoryNotPresent => EK::DirectoryExpired, E::NetDirOlder => EK::TorDirectoryError, @@ -416,3 +422,21 @@ fn sqlite_error_kind(e: &rusqlite::Error) -> ErrorKind { _ => EK::Internal, } } + +/// An error coming from a read-only store. +#[derive(Error, Debug, Clone)] +#[non_exhaustive] +pub enum ReadOnlyStorageError { + /// We couldn't find the database. + #[error("The database could not be found.")] + NoDatabase, + + /// A schema version that is not current. + #[error("Incomaptible data storage schema v{schema}. (We expected v{supported})")] + IncompatibleSchema { + /// The schema version in the database + schema: u32, + /// The schema that we actually support. + supported: u32, + }, +} |
