sos_login/
error.rs

1use sos_core::{SecretId, VaultId};
2use thiserror::Error;
3use urn::Urn;
4
5/// Errors generated by the library.
6#[derive(Debug, Error)]
7pub enum Error {
8    /// Error generated when an account does not exist.
9    #[error("account not found '{0}'")]
10    NoAccount(String),
11
12    /// Error generated when a folder password could not be located.
13    #[error("folder password not found for '{0}'")]
14    NoFolderPassword(VaultId),
15
16    /// Error generated when a login vault does not contain
17    /// the identity bit flag.
18    #[error("vault is not an identity vault")]
19    NotIdentityFolder,
20
21    /// Error generated parsing an AGE identity from a string.
22    #[error("failed to parse AGE identity: '{0}'")]
23    AgeIdentityParse(String),
24
25    /// Error generated when an identity key could not be
26    /// found in an identity vault.
27    #[error("identity vault does not contain a valid account identity key")]
28    NoIdentityKey,
29
30    /// Error generated when a vault entry in an identity vault is of
31    /// the wrong secret kind.
32    #[error("vault entry for {0} is of an unexpected type")]
33    VaultEntryKind(String),
34
35    /// Error generated when attempting to parse an AGE identity.
36    #[error(r#"invalid x25519 identity '{0}'"#)]
37    InvalidX25519Identity(String),
38
39    /// Error generated when a vault does not contain a secret by URN.
40    #[error("vault {0} does not contain {1}")]
41    NoSecretUrn(VaultId, Urn),
42
43    /// Error generated when a vault does not contain a secret by identifier.
44    #[error("vault {0} does not contain {1}")]
45    NoSecretId(VaultId, SecretId),
46
47    /// Error generated when a file encryption password could not be found.
48    #[error("could not find file encryption password in identity folder")]
49    NoFileEncryptionPassword,
50
51    /// Error generated converting to fixed length slice.
52    #[error(transparent)]
53    TryFromSlice(#[from] std::array::TryFromSliceError),
54
55    /// Error generated by the IO module.
56    #[error(transparent)]
57    Io(#[from] std::io::Error),
58
59    /// Error generated by the core library.
60    #[error(transparent)]
61    Core(#[from] sos_core::Error),
62
63    /// Authentication errors.
64    #[error(transparent)]
65    Authentication(#[from] sos_core::AuthenticationError),
66
67    /// Error generated by the backend library.
68    #[error(transparent)]
69    Backend(#[from] sos_backend::Error),
70
71    /// Error generated by the database library.
72    #[error(transparent)]
73    Database(#[from] sos_backend::database::Error),
74
75    /// Error generated by the async sqlite library.
76    #[error(transparent)]
77    AsyncSqlite(#[from] sos_backend::database::async_sqlite::Error),
78
79    /// Error generated by the sqlite library.
80    #[error(transparent)]
81    Sqlite(#[from] sos_backend::database::async_sqlite::rusqlite::Error),
82
83    /// Error generated by the password library.
84    #[error(transparent)]
85    Password(#[from] sos_password::Error),
86
87    /// Error generated by the signer library.
88    #[error(transparent)]
89    Signer(#[from] sos_signer::Error),
90
91    /// Error generated by the vault library.
92    #[error(transparent)]
93    Vault(#[from] sos_vault::Error),
94
95    /// Error generated by the Ed25519 library.
96    #[error(transparent)]
97    Ed25519(#[from] ed25519_dalek::ed25519::Error),
98
99    /// Error generated by the URN library.
100    #[error(transparent)]
101    Urn(#[from] urn::Error),
102}