1use card_backend::SmartcardError;
14
15use crate::ocard::StatusBytes;
16
17#[derive(thiserror::Error, Debug)]
19#[non_exhaustive]
20pub enum Error {
21 #[error("Error interacting with smartcard: {0}")]
22 Smartcard(SmartcardError),
23
24 #[error("OpenPGP card error status: {0}")]
25 CardStatus(StatusBytes),
26
27 #[error("Command too long ({0} bytes)")]
28 CommandTooLong(usize),
29
30 #[error("Unexpected response length: {0}")]
31 ResponseLength(usize),
32
33 #[error("Data not found: {0}")]
34 NotFound(String),
35
36 #[error("Couldn't parse data: {0}")]
37 ParseError(String),
38
39 #[error("Unsupported algorithm: {0}")]
40 UnsupportedAlgo(String),
41
42 #[error("Unsupported feature: {0}")]
43 UnsupportedFeature(String),
44
45 #[error("Internal error: {0}")]
47 InternalError(String),
48}
49
50impl From<StatusBytes> for Error {
51 fn from(oce: StatusBytes) -> Self {
52 Error::CardStatus(oce)
53 }
54}
55
56impl From<SmartcardError> for Error {
57 fn from(sce: SmartcardError) -> Self {
58 Error::Smartcard(sce)
59 }
60}