* Refactoring.
This commit is contained in:
parent
88fb4f6e53
commit
c4cb6ea2bc
|
@ -497,14 +497,8 @@ void NormalisationGoal::buildDone()
|
||||||
/* Check the exit status. */
|
/* Check the exit status. */
|
||||||
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
||||||
deleteTmpDir(false);
|
deleteTmpDir(false);
|
||||||
if (WIFEXITED(status))
|
throw Error(format("builder for `%1%' %2%")
|
||||||
throw Error(format("builder for `%1%' failed with exit code %2%")
|
% nePath % statusToString(status));
|
||||||
% nePath % WEXITSTATUS(status));
|
|
||||||
else if (WIFSIGNALED(status))
|
|
||||||
throw Error(format("builder for `%1%' failed due to signal %2%")
|
|
||||||
% nePath % WTERMSIG(status));
|
|
||||||
else
|
|
||||||
throw Error(format("builder for `%1%' failed died abnormally") % nePath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteTmpDir(true);
|
deleteTmpDir(true);
|
||||||
|
@ -1425,17 +1419,9 @@ void SubstitutionGoal::finished()
|
||||||
debug(format("substitute for `%1%' finished") % storePath);
|
debug(format("substitute for `%1%' finished") % storePath);
|
||||||
|
|
||||||
/* Check the exit status. */
|
/* Check the exit status. */
|
||||||
/* !!! cut & paste */
|
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
||||||
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
throw Error(format("builder for `%1%' %2%")
|
||||||
if (WIFEXITED(status))
|
% storePath % statusToString(status));
|
||||||
throw Error(format("builder for `%1%' failed with exit code %2%")
|
|
||||||
% storePath % WEXITSTATUS(status));
|
|
||||||
else if (WIFSIGNALED(status))
|
|
||||||
throw Error(format("builder for `%1%' failed due to signal %2%")
|
|
||||||
% storePath % WTERMSIG(status));
|
|
||||||
else
|
|
||||||
throw Error(format("builder for `%1%' failed died abnormally") % storePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pathExists(storePath))
|
if (!pathExists(storePath))
|
||||||
throw Error(format("substitute did not produce path `%1%'") % storePath);
|
throw Error(format("substitute did not produce path `%1%'") % storePath);
|
||||||
|
|
|
@ -164,7 +164,8 @@ void copyPath(const Path & src, const Path & dst)
|
||||||
throw SysError("waiting for child");
|
throw SysError("waiting for child");
|
||||||
|
|
||||||
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
||||||
throw Error("cannot copy file: child died");
|
throw Error(format("cannot copy `%1% to `%2%': child %3%")
|
||||||
|
% src % dst % statusToString(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -491,3 +491,16 @@ Strings unpackStrings(const string & s)
|
||||||
|
|
||||||
return strings;
|
return strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string statusToString(int status)
|
||||||
|
{
|
||||||
|
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
||||||
|
if (WIFEXITED(status))
|
||||||
|
return (format("failed with exit code %2%") % WEXITSTATUS(status)).str();
|
||||||
|
else if (WIFSIGNALED(status))
|
||||||
|
return (format("failed due to signal %2%") % WTERMSIG(status)).str();
|
||||||
|
else
|
||||||
|
return "died abnormally";
|
||||||
|
} else return "succeeded";
|
||||||
|
}
|
||||||
|
|
|
@ -221,4 +221,9 @@ string packStrings(const Strings & strings);
|
||||||
Strings unpackStrings(const string & s);
|
Strings unpackStrings(const string & s);
|
||||||
|
|
||||||
|
|
||||||
|
/* Convert the exit status of a child as returned by wait() into an
|
||||||
|
error string. */
|
||||||
|
string statusToString(int status);
|
||||||
|
|
||||||
|
|
||||||
#endif /* !__UTIL_H */
|
#endif /* !__UTIL_H */
|
||||||
|
|
Loading…
Reference in a new issue