ate_crypto/error/
crypto_error.rs

1use error_chain::error_chain;
2
3error_chain! {
4    types {
5        CryptoError, CryptoErrorKind, ResultExt, Result;
6    }
7    errors {
8        NoIvPresent {
9            description("no initialization vector")
10            display("no initialization vector")
11        }
12    }
13}
14
15impl From<CryptoError> for std::io::Error {
16    fn from(error: CryptoError) -> Self {
17        match error {
18            CryptoError(CryptoErrorKind::NoIvPresent, _) => std::io::Error::new(
19                std::io::ErrorKind::Other,
20                "The metadata does not have IV component present",
21            ),
22            _ => std::io::Error::new(
23                std::io::ErrorKind::Other,
24                "An unknown error occured while performing ate crypto",
25            ),
26        }
27    }
28}