diff options
author | qkzk <qu3nt1n@gmail.com> | 2022-12-10 23:52:09 +0100 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2022-12-10 23:52:09 +0100 |
commit | ba3c218ac7aa99177fe6fcbca878d72667161605 (patch) | |
tree | 33a8c1ede9b584f24b22c1f5d0a9158484002e2b /src/marks.rs | |
parent | 3f332986bc89fda5e83bc65d1c647b5069294fde (diff) |
more detail on errors, parse keymaps directly
Diffstat (limited to 'src/marks.rs')
-rw-r--r-- | src/marks.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/marks.rs b/src/marks.rs index 00e83b5..b0da6a7 100644 --- a/src/marks.rs +++ b/src/marks.rs @@ -6,7 +6,7 @@ use std::path::{Path, PathBuf}; use log::info; -use crate::fm_error::{FmError, FmResult}; +use crate::fm_error::{ErrorVariant, FmError, FmResult}; static MARKS_FILEPATH: &str = "~/.config/fm/marks.cfg"; @@ -50,7 +50,10 @@ impl Marks { pub fn new_mark(&mut self, ch: char, path: PathBuf) -> FmResult<()> { if ch == ':' { - return Err(FmError::new("':' can't be used as a mark")); + return Err(FmError::new( + ErrorVariant::CUSTOM("new_mark".to_owned()), + "':' can't be used as a mark", + )); } self.marks.insert(ch, path); self.save_marks() @@ -74,7 +77,12 @@ impl Marks { fn path_as_string(path: &Path) -> FmResult<String> { Ok(path .to_str() - .ok_or_else(|| FmError::new("Unreadable path"))? + .ok_or_else(|| { + FmError::new( + ErrorVariant::CUSTOM("path_as_string".to_owned()), + "Unreadable path", + ) + })? .to_owned()) } @@ -90,10 +98,12 @@ impl Marks { let mut s = "".to_owned(); s.push(*ch); s.push_str(" "); - s.push_str( - path.to_str() - .ok_or_else(|| FmError::new("Unreadable path"))?, - ); + s.push_str(path.to_str().ok_or_else(|| { + FmError::new( + ErrorVariant::CUSTOM("format mark".to_owned()), + "Unreadable path", + ) + })?); s.push('\n'); Ok(s) } |