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    /// does not exist in the source database.
28    #[error(
29        "import failed, account '{0}' does not exist in the backup archive"
30    )]
31    ImportSourceNotExists(AccountId),
32
33    /// Error generated attempting to import an account that
34    /// already exists in the target database.
35    #[error("import failed, account '{0}' already exists")]
36    ImportTargetExists(AccountId),
37
38    /// Error generated when the checksum for a database does not
39    /// match the manifest.
40    #[error("database checksum is invalid, expected '{0}' but computed '{1}' (archive may be corrupt?)")]
41    DatabaseChecksum(CommitHash, CommitHash),
42
43    /// Error generated converting to fixed size slice.
44    #[error(transparent)]
45    TryFromSlice(#[from] std::array::TryFromSliceError),
46
47    /// Errors generated by the database library.
48    #[error(transparent)]
49    Database(#[from] crate::Error),
50
51    /// Errors generated by the IO module.
52    #[error(transparent)]
53    Io(#[from] std::io::Error),
54
55    /// Error generated by the JSON library.
56    #[error(transparent)]
57    Json(#[from] serde_json::Error),
58
59    /// Error generated by the ZIP archive library.
60    #[error(transparent)]
61    ZipArchive(#[from] sos_archive::Error),
62
63    /// Errors generated by the async sqlite library.
64    #[error(transparent)]
65    AsyncSqlite(#[from] async_sqlite::Error),
66
67    /// Errors generated by the rusqlite library.
68    #[error(transparent)]
69    Rusqlite(#[from] async_sqlite::rusqlite::Error),
70
71    /// Errors generated by refinery migration library.
72    #[error(transparent)]
73    Refinery(#[from] refinery::Error),
74
75    /// Errors generated by the core library.
76    #[error(transparent)]
77    Core(#[from] sos_core::Error),
78
79    /// Errors generated by the vault library.
80    #[error(transparent)]
81    Vault(#[from] sos_vault::Error),
82}