signstar_crypto/error.rs
1//! Error handling.
2
3use std::path::PathBuf;
4
5/// An error that may occur when working with cryptographic types for Signstar.
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8 /// A [`change_user_run::Error`] occurred.
9 #[error(transparent)]
10 ChangeUserRun(#[from] change_user_run::Error),
11
12 /// An I/O error occurred for a file.
13 #[error("I/O error for file {path} while {context}: {source}")]
14 IoPath {
15 /// The path to the file for which the error occurred.
16 path: PathBuf,
17 /// The context in which the error occurs.
18 ///
19 /// This is meant to complete the sentence "I/O error for file {path} while ".
20 context: &'static str,
21 /// The error source.
22 source: std::io::Error,
23 },
24
25 /// An error related to keys occurred.
26 #[error("Key error: {0}")]
27 Key(#[from] crate::key::Error),
28
29 /// An error related to OpenPGP occurred.
30 #[error("OpenPGP error: {0}")]
31 OpenPgp(#[from] crate::openpgp::Error),
32
33 /// An error related to passphrase handling occurred.
34 #[error("Passphrase error: {0}")]
35 Passphrase(#[from] crate::passphrase::Error),
36
37 /// An error related to secret file reading or writing occurred.
38 #[error("Secret file error: {0}")]
39 SecretFile(#[from] crate::secret_file::Error),
40
41 /// An error related to raw signing occurred.
42 #[error("Signer error: {0}")]
43 Signer(#[from] crate::signer::error::Error),
44
45 /// A test helper error occurred.
46 #[error("Test helper error: {0}")]
47 #[cfg(feature = "_test-helpers")]
48 TestHelper(#[from] crate::test::Error),
49}