1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, BottleError>;
8
9#[derive(Error, Debug, Clone, PartialEq)]
26pub enum BottleError {
27 #[error("No appropriate key available to decrypt")]
28 NoAppropriateKey,
29
30 #[error("Signature verification failed")]
31 VerifyFailed,
32
33 #[error("Key not found in keychain/IDCard")]
34 KeyNotFound,
35
36 #[error("Group not found in IDCard")]
37 GroupNotFound,
38
39 #[error("Key not authorized for the operation")]
40 KeyUnfit,
41
42 #[error("No valid recipient for encryption")]
43 EncryptNoRecipient,
44
45 #[error("Invalid key type")]
46 InvalidKeyType,
47
48 #[error("Serialization error: {0}")]
49 Serialization(String),
50
51 #[error("Deserialization error: {0}")]
52 Deserialization(String),
53
54 #[error("Encryption error: {0}")]
55 Encryption(String),
56
57 #[error("Decryption error: {0}")]
58 Decryption(String),
59
60 #[error("IO error: {0}")]
61 Io(String),
62
63 #[error("Invalid format")]
64 InvalidFormat,
65
66 #[error("Unsupported algorithm")]
67 UnsupportedAlgorithm,
68}
69
70impl From<std::io::Error> for BottleError {
71 fn from(err: std::io::Error) -> Self {
72 BottleError::Io(err.to_string())
73 }
74}