1use crate::crypto::CryptoError;
4use crate::github::GitHubError;
5use crate::vault::VaultError;
6
7#[derive(Debug)]
9pub enum MurkError {
10 Vault(VaultError),
12 Crypto(CryptoError),
14 Integrity(String),
16 Key(String),
18 Recipient(String),
20 Secret(String),
22 GitHub(GitHubError),
24 Io(std::io::Error),
26}
27
28impl std::fmt::Display for MurkError {
29 #[allow(clippy::match_same_arms)]
30 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31 match self {
32 MurkError::Vault(e) => write!(f, "{e}"),
33 MurkError::Crypto(e) => write!(f, "{e}"),
34 MurkError::Integrity(msg) => write!(f, "integrity check failed: {msg}"),
35 MurkError::Key(msg) => write!(f, "{msg}"),
36 MurkError::Recipient(msg) => write!(f, "{msg}"),
37 MurkError::Secret(msg) => write!(f, "{msg}"),
38 MurkError::GitHub(e) => write!(f, "{e}"),
39 MurkError::Io(e) => write!(f, "I/O error: {e}"),
40 }
41 }
42}
43
44impl std::error::Error for MurkError {
45 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
46 match self {
47 MurkError::Io(e) => Some(e),
48 _ => None,
49 }
50 }
51}
52
53impl From<VaultError> for MurkError {
54 fn from(e: VaultError) -> Self {
55 MurkError::Vault(e)
56 }
57}
58
59impl From<CryptoError> for MurkError {
60 fn from(e: CryptoError) -> Self {
61 MurkError::Crypto(e)
62 }
63}
64
65impl From<GitHubError> for MurkError {
66 fn from(e: GitHubError) -> Self {
67 MurkError::GitHub(e)
68 }
69}
70
71impl From<std::io::Error> for MurkError {
72 fn from(e: std::io::Error) -> Self {
73 MurkError::Io(e)
74 }
75}