diff options
| author | Irene Knapp <ireneista@internetsafetylabs.org> | 2025-12-17 15:16:20 -0800 |
|---|---|---|
| committer | Irene Knapp <ireneista@internetsafetylabs.org> | 2025-12-18 13:37:52 -0800 |
| commit | d15feffcdb262f5e4686297e156319591895a945 (patch) | |
| tree | 9bf3fd01d8885c0cfba7fec810dca4bb28bf0552 /src/error.rs | |
| parent | 01b7b60dc260aa7cf1dab6c15db13a88d5d92ada (diff) | |
implement the secret-list command
Change-Id: I5e1570940fedf52bb560fd824270e201757004ed
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/error.rs b/src/error.rs index 86e7928..199a0f4 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,12 +1,15 @@ #![forbid(unsafe_code)] +use std::fmt::{ Display, Formatter }; pub type Result<T> = std::result::Result<T, Error>; #[derive(Debug)] pub enum Error { - IO(std::io::Error), + CommandLine(::clap::error::Error), Internal(String), + IO(std::io::Error), + UTF8, } impl From<std::io::Error> for Error { @@ -15,3 +18,34 @@ impl From<std::io::Error> for Error { } } +impl From<::clap::error::Error> for Error { + fn from(value: ::clap::error::Error) -> Self { + Error::CommandLine(value) + } +} + +impl From<std::string::FromUtf8Error> for Error { + fn from(_value: std::string::FromUtf8Error) -> Self { + Error::UTF8 + } +} + +impl Display for Error { + fn fmt(&self, fmt: &mut Formatter<'_>) -> std::fmt::Result { + match self { + Error::CommandLine(error) => { + write!(fmt, "{}", error.to_string()) + }, + Error::Internal(string) => { + write!(fmt, "{}", string) + }, + Error::IO(error) => { + write!(fmt, "{}", error.to_string()) + }, + Error::UTF8 => { + write!(fmt, "Invalid UTF8 received") + }, + } + } +} + |