-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from qboileau/visit-then-apply
List operations before running them on filesystem
- Loading branch information
Showing
9 changed files
with
895 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
use failure::Fail; | ||
use std::path::{Path, PathBuf}; | ||
use std::clone::Clone; | ||
use std::fmt::*; | ||
use std::ops::Deref; | ||
|
||
#[derive(Fail, Debug, Clone)] | ||
pub(crate) enum AppError { | ||
#[fail(display = "Unable to stow {} to {} cause : {}", source, target, cause)] | ||
StowPathError { | ||
source: ErrorPath, | ||
target: ErrorPath, | ||
cause: String | ||
}, | ||
|
||
#[fail(display = "An IO error append : {}", msg)] | ||
IOError { | ||
msg: String | ||
}, | ||
|
||
#[fail(display = "Unable to apply stow because of previous errors")] | ||
ApplyError | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct ErrorPath { path: PathBuf } | ||
|
||
impl Deref for ErrorPath { | ||
type Target = PathBuf; | ||
|
||
fn deref(&self) -> &PathBuf { | ||
&self.path | ||
} | ||
} | ||
|
||
impl Display for ErrorPath { | ||
fn fmt(&self, f: &mut Formatter) -> Result { | ||
write!(f, "{}", self.display()) | ||
} | ||
} | ||
|
||
impl From<PathBuf> for ErrorPath { | ||
fn from(path: PathBuf) -> ErrorPath { | ||
ErrorPath { path } | ||
} | ||
} | ||
|
||
impl<'a> From<&'a Path> for ErrorPath { | ||
fn from(path: &Path) -> Self { | ||
ErrorPath { path: path.to_path_buf() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.