diem_config/config/
error.rs1use thiserror::Error;
9
10#[derive(Debug, Error)]
11pub enum Error {
12 #[error("Invariant violation: {0}")]
13 InvariantViolation(String),
14 #[error("Error accessing {0}: {1}")]
15 IO(String, #[source] std::io::Error),
16 #[error("Error (de)serializing {0}: {1}")]
17 BCS(&'static str, #[source] bcs::Error),
18 #[error("Error (de)serializing {0}: {1}")]
19 Yaml(String, #[source] yaml_serde::Error),
20 #[error("Config is missing expected value: {0}")]
21 Missing(&'static str),
22}
23
24pub fn invariant(cond: bool, msg: String) -> Result<(), Error> {
25 if !cond {
26 Err(Error::InvariantViolation(msg))
27 } else {
28 Ok(())
29 }
30}