use thiserror::Error;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum CryptexdError {
#[error("cryptexd routine `{routine}` failed: {detail}")]
RoutineFailed { routine: String, detail: String },
#[error("cryptexd reply missing required field `{0}`")]
MissingField(&'static str),
#[error("cryptexd returned a malformed {0}-byte nonce structure")]
MalformedNonce(usize),
#[error("developer disk image bundle is unusable: {0}")]
BadDdiBundle(String),
}
impl CryptexdError {
pub fn sub_code(&self) -> i32 {
match self {
Self::RoutineFailed { .. } => 1,
Self::MissingField(_) => 2,
Self::MalformedNonce(_) => 3,
Self::BadDdiBundle(_) => 4,
}
}
}