Skip to content

Commit

Permalink
more adapted error message in case of wrong folder
Browse files Browse the repository at this point in the history
  • Loading branch information
o2sh committed Dec 11, 2018
1 parent 17ea45d commit d93fe8a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ struct Configuration {
}

fn get_configuration() -> Result<Configuration> {
let repo = Repository::open("./").map_err(|_| Error::GitNotInstalled)?;
let repo = Repository::open("./").map_err(|_| Error::NotGitRepo)?;
let config = repo.config().map_err(|_| Error::NoGitData)?;
let mut remote_url = String::new();
let mut repository_name = String::new();
Expand Down Expand Up @@ -409,6 +409,8 @@ enum Error {
NoGitData,
/// An IO error occoured while reading ./
ReadDirectory,
/// Not in a Git Repo
NotGitRepo,
}

impl fmt::Debug for Error {
Expand All @@ -417,7 +419,8 @@ impl fmt::Debug for Error {
Error::SourceCodeNotFound => "Could not find any source code in this directory",
Error::GitNotInstalled => "Git failed to execute",
Error::NoGitData => "Could not retrieve git configuration data",
Error::ReadDirectory => "Could read directory ./",
Error::ReadDirectory => "Could not read directory ./",
Error::NotGitRepo => "You are not at the root of a Git Repo",
};
write!(f, "{}", content)
}
Expand Down

0 comments on commit d93fe8a

Please sign in to comment.