use acme_proxy_core::error::Problem;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{0}")]
Problem(Problem),
#[error("the terms of service have not been agreed to")]
TermsNotAgreed,
#[error("the new key already belongs to account {holder}")]
KeyChangeConflict { holder: uuid::Uuid },
}
impl From<Problem> for Error {
fn from(problem: Problem) -> Self {
Self::Problem(problem)
}
}
impl From<Error> for Problem {
fn from(error: Error) -> Self {
match error {
Error::Problem(problem) => problem,
Error::TermsNotAgreed => Problem::user_action_required(
"Terms of service must be agreed to before an account can be created",
),
Error::KeyChangeConflict { .. } => Problem::key_change_conflict(
"The new key is already associated with a different account",
),
}
}
}