error.rs (2247B)
1 use thiserror::Error; 2 3 /// Stable, value-free runtime-management metadata failures. 4 #[derive(Clone, Copy, Debug, Error, PartialEq, Eq)] 5 pub enum RadrootsRuntimeManagerError { 6 #[error("runtime management contract exceeds its size limit")] 7 ContractTooLarge, 8 #[error("parse runtime management contract failed")] 9 Parse, 10 #[error("runtime management schema is unsupported")] 11 UnexpectedSchema, 12 #[error("runtime management schema version is unsupported")] 13 UnexpectedSchemaVersion, 14 #[error("runtime management contract violates the hardened service inventory")] 15 InvalidContract, 16 #[error("management mode does not support the selected profile")] 17 UnsupportedProfile, 18 #[error("runtime is not a hardened service target")] 19 UnsupportedServiceTarget, 20 #[error("runtime context does not match the selected management target")] 21 ContextMismatch, 22 #[error("bounded local admin client construction failed")] 23 AdminClient, 24 #[error("bounded local admin request failed")] 25 AdminRequest, 26 #[error("service status response does not match the selected runtime context")] 27 StatusContractMismatch, 28 } 29 30 #[cfg(test)] 31 mod tests { 32 use std::error::Error as _; 33 34 use super::RadrootsRuntimeManagerError; 35 36 #[test] 37 fn every_public_failure_is_fixed_value_free_and_source_free() { 38 for error in [ 39 RadrootsRuntimeManagerError::ContractTooLarge, 40 RadrootsRuntimeManagerError::Parse, 41 RadrootsRuntimeManagerError::UnexpectedSchema, 42 RadrootsRuntimeManagerError::UnexpectedSchemaVersion, 43 RadrootsRuntimeManagerError::InvalidContract, 44 RadrootsRuntimeManagerError::UnsupportedProfile, 45 RadrootsRuntimeManagerError::UnsupportedServiceTarget, 46 RadrootsRuntimeManagerError::ContextMismatch, 47 RadrootsRuntimeManagerError::AdminClient, 48 RadrootsRuntimeManagerError::AdminRequest, 49 RadrootsRuntimeManagerError::StatusContractMismatch, 50 ] { 51 let rendered = format!("{error} {error:?}"); 52 assert!(!rendered.contains('/')); 53 assert!(!rendered.contains("secret-value")); 54 assert!(error.source().is_none()); 55 } 56 } 57 }