Skip to main content

nibkeep_keys/
error.rs

1//! Why keys could not be unlocked or saved.
2
3use nibkeep_crypto::CryptoError;
4
5/// Why keys could not be unlocked or saved.
6#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum KeysError {
9	/// The passphrase does not open the compartment, or the file was changed.
10	#[error("the passphrase is wrong, or the key file was changed")]
11	WrongPassphrase,
12	/// The keystore's key does not open the compartment, or the file was changed.
13	#[error("the key in the keystore does not open the key file")]
14	WrongKey,
15	/// The compartment is protected another way than the unlocker offers.
16	#[error("the key file is protected another way")]
17	WrongUnlocker,
18	/// The key file has no secrets compartment.
19	#[error("the key file holds no secrets keys")]
20	NoSecrets,
21	/// The platform's keystore failed or does not have the key.
22	#[error("the keystore failed: {0}")]
23	Keystore(#[from] keyring_core::Error),
24	/// The passphrase cannot be used.
25	#[error(transparent)]
26	Crypto(#[from] CryptoError),
27	/// The key file is not well-formed.
28	#[error("the key file is damaged: {0}")]
29	Damaged(String),
30	/// The file system failed.
31	#[error(transparent)]
32	Io(#[from] std::io::Error),
33}