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/parent_directory.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/parent_directory.rs')
-rw-r--r-- | src/commands/parent_directory.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/commands/parent_directory.rs b/src/commands/parent_directory.rs index abafc21..f0f690d 100644 --- a/src/commands/parent_directory.rs +++ b/src/commands/parent_directory.rs @@ -1,6 +1,6 @@ use crate::commands::{JoshutoCommand, JoshutoRunnable}; use crate::context::JoshutoContext; -use crate::error::JoshutoError; +use crate::error::{JoshutoError, JoshutoResult}; use crate::history::DirectoryHistory; use crate::window::JoshutoView; @@ -18,7 +18,7 @@ impl ParentDirectory { pub fn parent_directory( context: &mut JoshutoContext, view: &JoshutoView, - ) -> Result<(), std::io::Error> { + ) -> std::io::Result<()> { let curr_tab = &mut context.tabs[context.curr_tab_index]; if !curr_tab.curr_path.pop() { return Ok(()); @@ -49,14 +49,10 @@ impl std::fmt::Display for ParentDirectory { } impl JoshutoRunnable for ParentDirectory { - fn execute( - &self, - context: &mut JoshutoContext, - view: &JoshutoView, - ) -> Result<(), JoshutoError> { + fn execute(&self, context: &mut JoshutoContext, view: &JoshutoView) -> JoshutoResult<()> { match Self::parent_directory(context, view) { Ok(_) => Ok(()), - Err(e) => Err(JoshutoError::IO(e)), + Err(e) => Err(JoshutoError::from(e)), } } } |