diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-04-28 08:11:06 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-04-28 08:16:42 -0400 |
commit | b3e9d955b0a60b55a9edeed93e00ce2772f5b467 (patch) | |
tree | 31b92eea0e2a3e4f506d7df7932b72f865fbc187 /src/error.rs | |
parent | 6f0ae400152d02f43ffd2911040302c97d84178f (diff) |
from_args has been changed from option to result
- attempt to fix progress bars
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs index a964132..bae1e0c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,3 +1,31 @@ pub enum JoshutoError { IO(std::io::Error), } + +/* +pub enum KeymapErrorKind { + Parse, + UnknownArgument, + UnknownCommand, +} +*/ + +pub struct KeymapError { + pub command: Option<&'static str>, + pub error: String, +} + +impl KeymapError { + pub fn new(command: Option<&'static str>, error: String) -> Self { + KeymapError { command, error } + } +} + +impl std::fmt::Display for KeymapError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self.command { + Some(s) => write!(f, "{}: {}", s, self.error), + None => write!(f, "{}", self.error), + } + } +} |