signstar_yubihsm2/object/error.rs
1//! Error handling for objects used in signstar-yubihsm2.
2
3/// The error that may occur when using a YubiHSM2 device.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6 /// An ID is invalid.
7 #[error("YubiHSM2 ID {id} is invalid, because {reason}")]
8 InvalidId {
9 /// The reason why the `id` is invalid.
10 ///
11 /// This is supposed to complete the sentence "YubiHSM2 ID {id} is invalid, because ".
12 reason: String,
13
14 /// The invalid ID.
15 id: String,
16 },
17
18 /// Empty set of domains encountered.
19 #[error("Empty set of domains encountered")]
20 EmptySetOfDomains,
21
22 /// A [`getrandom::Error`] occurred.
23 #[error("Get random error while {context}: {source}")]
24 GetRandom {
25 /// The context in which the error occurred.
26 ///
27 /// This is meant to complete the sentence "Get random error while ".
28 context: &'static str,
29
30 /// The error source.
31 source: getrandom::Error,
32 },
33
34 /// An [`argon2::Error`] occurred.
35 #[error("Argon2 error while {context}: {source}")]
36 Argon2 {
37 /// The context in which the error occurred.
38 ///
39 /// This is meant to complete the sentence "Argon2 error while ".
40 context: &'static str,
41
42 /// The error source.
43 source: argon2::Error,
44 },
45}