Files
age-plugin-yubikey/src/error.rs
T
2020-12-31 23:01:22 +00:00

32 lines
781 B
Rust

use std::fmt;
use std::io;
pub enum Error {
Io(io::Error),
}
impl From<io::Error> for Error {
fn from(e: io::Error) -> Self {
Error::Io(e)
}
}
// Rust only supports `fn main() -> Result<(), E: Debug>`, so we implement `Debug`
// manually to provide the error output we want.
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Io(e) => writeln!(f, "Failed to set up YubiKey: {}", e)?,
}
writeln!(f)?;
writeln!(
f,
"[ Did this not do what you expected? Could an error be more useful? ]"
)?;
write!(
f,
"[ Tell us: https://str4d.xyz/age-plugin-yubikey/report ]"
)
}
}