sos_database/archive/
error.rs

1use sos_core::{commit::CommitHash, AccountId};
2use std::path::PathBuf;
3use thiserror::Error;
4
5/// Errors generated creating and importing backup archives,
6#[derive(Debug, Error)]
7pub enum Error {
8    /// Archive file already exists.
9    #[error("archive file '{0}' already exists")]
10    ArchiveFileExists(PathBuf),
11
12    /// Archive file does not exist.
13    #[error("archive file '{0}' does not exist")]
14    ArchiveFileNotExists(PathBuf),
15
16    /// Error generated when an archive does not contain a
17    /// valid manifest file.
18    #[error("archive '{0}' manifest does not exist or is invalid")]
19    InvalidArchiveManifest(PathBuf),
20
21    /// Error generated when an archive does not contain the
22    /// database file.
23    #[error("archive '{0}' is missing the database '{1}'")]
24    NoDatabaseFile(PathBuf, String),
25
26    /// Error generated attempting to import an account that
27    /// already exists in the target database.
28    #[error("import failed, account '{0}' does not exist in source db")]
29    ImportSourceNotExists(AccountId),
30
31    /// Error generated attempting to import an account that
32    /// already exists in the target database.
33    #[error("import failed, account '{0}' already exists in target db")]
34    ImportTargetExists(AccountId),
35
36    /// Error generated when the checksum for a database does not
37    /// match the manifest.
38    #[error("database checksum is invalid, expected '{0}' but computed '{1}' (archive may be corrupt?)")]
39    DatabaseChecksum(CommitHash, CommitHash),
40
41    /// Error generated converting to fixed size slice.
42    #[error(transparent)]
43    TryFromSlice(#[from] std::array::TryFromSliceError),
44
45    /// Errors generated by the database library.
46    #[error(transparent)]
47    Database(#[from] crate::Error),
48
49    /// Errors generated by the IO module.
50    #[error(transparent)]
51    Io(#[from] std::io::Error),
52
53    /// Error generated by the JSON library.
54    #[error(transparent)]
55    Json(#[from] serde_json::Error),
56
57    /// Error generated by the ZIP archive library.
58    #[error(transparent)]
59    ZipArchive(#[from] sos_archive::Error),
60
61    /// Errors generated by the async sqlite library.
62    #[error(transparent)]
63    AsyncSqlite(#[from] async_sqlite::Error),
64
65    /// Errors generated by the rusqlite library.
66    #[error(transparent)]
67    Rusqlite(#[from] async_sqlite::rusqlite::Error),
68
69    /// Errors generated by refinery migration library.
70    #[error(transparent)]
71    Refinery(#[from] refinery::Error),
72
73    /// Errors generated by the core library.
74    #[error(transparent)]
75    Core(#[from] sos_core::Error),
76
77    /// Errors generated by the vault library.
78    #[error(transparent)]
79    Vault(#[from] sos_vault::Error),
80}