diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-04-24 10:36:49 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-04-24 10:36:49 -0400 |
commit | 6e95a6600679e6787a56ec5ef2a88fe0fbcf031f (patch) | |
tree | 4495e3a2bbb12b96b0b767ab1b844040c7cc4c71 /src/commands/reload_dir.rs | |
parent | e9a0d00d46ba4955f7d45d12aa412462e3daab39 (diff) |
add more error handling
- optimize/cleanup code
Diffstat (limited to 'src/commands/reload_dir.rs')
-rw-r--r-- | src/commands/reload_dir.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/commands/reload_dir.rs b/src/commands/reload_dir.rs index 454abf4..80e966b 100644 --- a/src/commands/reload_dir.rs +++ b/src/commands/reload_dir.rs @@ -15,15 +15,16 @@ impl ReloadDirList { "reload_dir_list" } - pub fn reload(context: &mut JoshutoContext, view: &JoshutoView) { + pub fn reload(context: &mut JoshutoContext, view: &JoshutoView) -> Result<(), std::io::Error> { let curr_tab = &mut context.tabs[context.curr_tab_index]; - curr_tab.reload_contents(&context.config_t.sort_option); + curr_tab.reload_contents(&context.config_t.sort_option)?; curr_tab.refresh( view, &context.config_t, &context.username, &context.hostname, ); + Ok(()) } } @@ -41,7 +42,10 @@ impl JoshutoRunnable for ReloadDirList { context: &mut JoshutoContext, view: &JoshutoView, ) -> Result<(), JoshutoError> { - Self::reload(context, view); + match Self::reload(context, view) { + Ok(_) => {} + Err(e) => return Err(JoshutoError::IO(e)), + } preview::preview_file( &mut context.tabs[context.curr_tab_index], view, |