sos_database/
error.rs

1use sos_core::{commit::CommitHash, VaultId};
2use thiserror::Error;
3
4/// Errors generated by the database library.
5#[derive(Debug, Error)]
6pub enum Error {
7    /// Error generated when a folder could not be found in the database.
8    #[error("folder '{0}' not found in the database")]
9    DatabaseFolderNotFound(VaultId),
10
11    /// Error generated when a login folder is required.
12    #[error("login folder not found for account id '{0}'")]
13    NoLoginFolder(i64),
14
15    /// Error generated when a target commit hash could not be found.
16    #[error("commit '{0}' could not be found")]
17    CommitNotFound(CommitHash),
18
19    /// Error generated when replacing events in an event log
20    /// does not compute the same root hash as the expected
21    /// checkpoint.
22    #[error("checkpoint verification failed, expected root hash '{checkpoint}' but computed '{computed}')")]
23    CheckpointVerification {
24        /// Checkpoint root hash.
25        checkpoint: CommitHash,
26        /// Computed root hash.
27        computed: CommitHash,
28    },
29
30    /// Errors generated by the core library.
31    #[error(transparent)]
32    Core(#[from] sos_core::Error),
33
34    /// Errors generated by the vault library.
35    #[error(transparent)]
36    Vault(#[from] sos_vault::Error),
37
38    /// Error generated converting to fixed length slice.
39    #[error(transparent)]
40    TryFromSlice(#[from] std::array::TryFromSliceError),
41
42    /// Error generated converting integers.
43    #[error(transparent)]
44    TryFromInt(#[from] std::num::TryFromIntError),
45
46    /// Errors generated by the UUID library.
47    #[error(transparent)]
48    Uuid(#[from] uuid::Error),
49
50    /// Errors generated by the IO module.
51    #[error(transparent)]
52    Io(#[from] std::io::Error),
53
54    /// Errors generated by the JSON library.
55    #[error(transparent)]
56    Json(#[from] serde_json::Error),
57
58    /// Errors generated by the URL library.
59    #[error(transparent)]
60    UrlParse(#[from] url::ParseError),
61
62    /// Errors generated by refinery migration library.
63    #[error(transparent)]
64    Refinery(#[from] refinery::Error),
65
66    /// Errors generated by the async sqlite library.
67    #[error(transparent)]
68    AsyncSqlite(#[from] async_sqlite::Error),
69
70    /// Errors generated by the rusqlite library.
71    #[error(transparent)]
72    Rusqlite(#[from] async_sqlite::rusqlite::Error),
73
74    #[cfg(feature = "system-messages")]
75    /// Errors generated by the URN library.
76    #[error(transparent)]
77    Urn(#[from] urn::Error),
78}