tor_keymgr/keystore/ephemeral/
err.rs1use std::sync::Arc;
4
5use tor_error::{ErrorKind, HasKind};
6
7use crate::KeystoreError;
8
9#[derive(thiserror::Error, Debug, Clone)]
12pub(crate) enum ArtiEphemeralKeystoreError {
13 #[error("unable to build ArtiPath from KeySpecifier")]
15 ArtiPathUnavailableError(#[from] crate::key_specifier::ArtiPathUnavailableError),
16 #[error("{0}")]
18 SshKeySerialize(#[from] ssh_key::Error),
19
20 #[error("Operation not supported: {action}")]
22 NotSupported {
23 action: &'static str,
25 },
26}
27
28impl KeystoreError for ArtiEphemeralKeystoreError {}
29
30impl HasKind for ArtiEphemeralKeystoreError {
31 fn kind(&self) -> ErrorKind {
32 match self {
33 Self::ArtiPathUnavailableError(_) => ErrorKind::Other,
38 Self::SshKeySerialize(_) => ErrorKind::Other,
39 Self::NotSupported { .. } => ErrorKind::BadApiUsage,
40 }
41 }
42}
43
44impl From<ArtiEphemeralKeystoreError> for crate::Error {
45 fn from(e: ArtiEphemeralKeystoreError) -> Self {
46 crate::Error::Keystore(Arc::new(e))
47 }
48}