use auths_crypto::AuthsErrorInfo;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum OrgBundleError {
#[error("bundle integrity failure for '{id}': {reason}")]
Integrity {
id: String,
reason: String,
},
#[error("bundle is missing the KEL for delegated member '{member}'")]
MissingMemberKel {
member: String,
},
#[error("member '{member}' has no delegation seal in the org KEL")]
MissingDelegatorSeal {
member: String,
},
#[error("canonicalization failed: {0}")]
Canonicalize(String),
#[error("parse failed: {0}")]
Parse(String),
#[error("offboarding record invalid: {0}")]
RecordInvalid(String),
}
impl AuthsErrorInfo for OrgBundleError {
fn error_code(&self) -> &'static str {
match self {
Self::Integrity { .. } => "AUTHS-E2201",
Self::MissingMemberKel { .. } => "AUTHS-E2202",
Self::MissingDelegatorSeal { .. } => "AUTHS-E2203",
Self::Canonicalize(_) => "AUTHS-E2204",
Self::Parse(_) => "AUTHS-E2205",
Self::RecordInvalid(_) => "AUTHS-E2206",
}
}
fn suggestion(&self) -> Option<&'static str> {
match self {
Self::Integrity { .. } => Some(
"The bundle was modified after it was produced; obtain a fresh, untampered bundle",
),
Self::MissingMemberKel { .. } | Self::MissingDelegatorSeal { .. } => {
Some("The bundle is incomplete; re-produce it with `auths org bundle`")
}
Self::Canonicalize(_) | Self::Parse(_) => {
Some("The file is not a valid air-gapped org bundle; re-export it")
}
Self::RecordInvalid(_) => Some(
"The off-boarding record does not match the org KEL; obtain a fresh bundle from the org",
),
}
}
}