Skip to content

Commit

Permalink
primops: cleanup error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
LnL7 committed Jul 1, 2019
1 parent 6f99084 commit b022d8e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
15 changes: 7 additions & 8 deletions src/libexpr/primops/fetchGit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,13 @@ static void prim_fetchGit(EvalState & state, const Pos & pos, Value * * args, Va
try {
auto gitInfo = exportGit(state.store, url, ref, rev, name);
} catch (ExecError & e) {
if (e.status / 256 == 127) {
std::ostringstream out;
out << e.what() << std::endl;
out << "The program 'git' is currently not installed. It is required for builtins.fetchGit" << std::endl;
out << "You can install it by running the following:" << std::endl;
out << "nix-env -f '<nixpkgs>' -iA git";
throw ExecError(e.status, out.str());
}
if (WEXITSTATUS(e.status) == 127)
throw ExecError(e.status,
"%s\n"
"The program 'git' is currently not installed. It is required for builtins.fetchGit\n"
"You can install it by running the following:\n"
"nix-env -f '<nixpkgs>' -iA git",
e.what());
throw;
}

Expand Down
15 changes: 7 additions & 8 deletions src/libexpr/primops/fetchMercurial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,13 @@ static void prim_fetchMercurial(EvalState & state, const Pos & pos, Value * * ar
try {
auto hgInfo = exportMercurial(state.store, url, rev, name);
} catch (ExecError & e) {
if (e.status / 256 == 127) {
std::ostringstream out;
out << e.what() << std::endl;
out << "The program 'hg' is currently not installed. It is required for builtins.fetchMercurial" << std::endl;
out << "You can install it by running the following:" << std::endl;
out << "nix-env -f '<nixpkgs>' -iA mercurial";
throw ExecError(e.status, out.str());
}
if (WEXITSTATUS(e.status) == 127)
throw ExecError(e.status,
"%s\n"
"The program 'hg' is currently not installed. It is required for builtins.fetchMercurial\n"
"You can install it by running the following:\n"
"nix-env -f '<nixpkgs>' -iA mercurial",
e.what());
throw;
}

Expand Down

0 comments on commit b022d8e

Please sign in to comment.