diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-06-29 22:19:47 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-06-29 22:23:31 -0400 |
commit | 65f0f33a564d91bd8126ce684c02f245e5ea9a1f (patch) | |
tree | bc9bb5d877cee131dc7870c5f9f5d0c71898efbd /src/commands/reload_dir.rs | |
parent | 58f6428e2aead58b7f930008b294ce56df59e3cb (diff) |
rework error system
- JoshutoErrorKind now envelops all possible errors by Joshuto
- JoshutoError behaves like std::io::Error
- add JoshutoResult
Diffstat (limited to 'src/commands/reload_dir.rs')
-rw-r--r-- | src/commands/reload_dir.rs | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/commands/reload_dir.rs b/src/commands/reload_dir.rs index b69b2c5..f126f02 100644 --- a/src/commands/reload_dir.rs +++ b/src/commands/reload_dir.rs @@ -1,6 +1,6 @@ use crate::commands::{JoshutoCommand, JoshutoRunnable}; use crate::context::JoshutoContext; -use crate::error::JoshutoError; +use crate::error::JoshutoResult; use crate::fs::JoshutoDirList; use crate::window::JoshutoView; @@ -47,19 +47,11 @@ impl std::fmt::Display for ReloadDirList { } impl JoshutoRunnable for ReloadDirList { - fn execute( - &self, - context: &mut JoshutoContext, - view: &JoshutoView, - ) -> Result<(), JoshutoError> { - match Self::reload(context.curr_tab_index, context) { - Ok(_) => { - let curr_tab = &mut context.tabs[context.curr_tab_index]; - curr_tab.refresh(view, &context.config_t); - ncurses::doupdate(); - Ok(()) - } - Err(e) => Err(JoshutoError::IO(e)), - } + fn execute(&self, context: &mut JoshutoContext, view: &JoshutoView) -> JoshutoResult<()> { + Self::reload(context.curr_tab_index, context)?; + let curr_tab = &mut context.tabs[context.curr_tab_index]; + curr_tab.refresh(view, &context.config_t); + ncurses::doupdate(); + Ok(()) } } |