apdu_core/error.rs
1use core::fmt::{Display, Formatter};
2
3use crate::Response;
4
5/// An error that was returned from the card or reader
6#[derive(Debug)]
7pub struct Error<'a> {
8 pub response: Response<'a>,
9}
10
11impl<'a> Display for Error<'a> {
12 fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
13 let (sw1, sw2) = self.response.trailer;
14
15 write!(f, "The APDU reader returned an error ({sw1:#X}, {sw2:#X}).")
16 }
17}
18
19#[cfg(feature = "std")]
20impl<'a> std::error::Error for Error<'a> {}