signstar_yubihsm2/automation/
error.rs1#[cfg(feature = "cli")]
4use std::fmt::Display;
5
6#[cfg(feature = "cli")]
7use crate::automation::command::CommandName;
8
9#[cfg(feature = "cli")]
14#[derive(Debug)]
15pub struct FileBackedScenarioReturnValueMismatch {
16 pub(crate) file_backed_scenario_command: CommandName,
18
19 pub(crate) command_return_value: CommandName,
21}
22
23#[cfg(feature = "cli")]
24impl Display for FileBackedScenarioReturnValueMismatch {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 write!(
27 f,
28 "{} -> {}",
29 self.file_backed_scenario_command, self.command_return_value
30 )
31 }
32}
33
34#[derive(Debug, thiserror::Error)]
36pub enum Error {
37 #[cfg(feature = "cli")]
39 #[error(
40 "Mismatches between commands in file backed scenarios and the collected return values exist:\n{}",
41 mismatches
42 .iter()
43 .map(ToString::to_string)
44 .collect::<Vec<_>>()
45 .join("\n")
46 )]
47 MismatchingReturnValueForFileBackedScenario {
48 mismatches: Vec<FileBackedScenarioReturnValueMismatch>,
50 },
51
52 #[error(
54 "The scenario tracks {scenario} authenticated command chains and the scenario return value {scenario_return_value}"
55 )]
56 MismatchingNumberOfAuthenticatedCommandChains {
57 scenario: usize,
59
60 scenario_return_value: usize,
62 },
63
64 #[error(
67 "The authenticated command chain tracks {authenticated_command_chain} commands while the list of command return values is {command_return_values}"
68 )]
69 MismatchingNumberOfCommands {
70 authenticated_command_chain: usize,
72
73 command_return_values: usize,
75 },
76}