use std::sync::Arc;
use tor_error::{ErrorKind, HasKind};
use crate::KeystoreError;
#[derive(thiserror::Error, Debug, Clone)]
pub(crate) enum ArtiEphemeralKeystoreError {
#[error("unable to build ArtiPath from KeySpecifier")]
ArtiPathUnavailableError(#[from] crate::key_specifier::ArtiPathUnavailableError),
#[error("{0}")]
SshKeySerialize(#[from] ssh_key::Error),
#[error("Operation not supported: {action}")]
NotSupported {
action: &'static str,
},
}
impl KeystoreError for ArtiEphemeralKeystoreError {}
impl HasKind for ArtiEphemeralKeystoreError {
fn kind(&self) -> ErrorKind {
match self {
Self::ArtiPathUnavailableError(_) => ErrorKind::Other,
Self::SshKeySerialize(_) => ErrorKind::Other,
Self::NotSupported { .. } => ErrorKind::BadApiUsage,
}
}
}
impl From<ArtiEphemeralKeystoreError> for crate::Error {
fn from(e: ArtiEphemeralKeystoreError) -> Self {
crate::Error::Keystore(Arc::new(e))
}
}