* Give a useful error message when an evaluation error occurs while

trying to upgrade a package.
This commit is contained in:
Eelco Dolstra 2009-10-13 09:30:17 +00:00
parent 53a4981fa2
commit 6f7d7bc1de

View file

@ -704,18 +704,20 @@ static void upgradeDerivations(Globals & globals,
foreach (DrvInfos::iterator, i, installedElems) { foreach (DrvInfos::iterator, i, installedElems) {
DrvName drvName(i->name); DrvName drvName(i->name);
try {
MetaInfo meta = i->queryMetaInfo(globals.state); MetaInfo meta = i->queryMetaInfo(globals.state);
if (keep(meta)) { if (keep(meta)) {
newElems.push_back(*i); newElems.push_back(*i);
continue; continue;
} }
/* Find the derivation in the input Nix expression with /* Find the derivation in the input Nix expression
the same name that satisfies the version constraints with the same name that satisfies the version
specified by upgradeType. If there are multiple constraints specified by upgradeType. If there are
matches, take the one with the highest priority. If multiple matches, take the one with the highest
there are still multiple matches, take the one with the priority. If there are still multiple matches,
highest version. */ take the one with the highest version. */
DrvInfos::iterator bestElem = availElems.end(); DrvInfos::iterator bestElem = availElems.end();
DrvName bestName; DrvName bestName;
foreach (DrvInfos::iterator, j, availElems) { foreach (DrvInfos::iterator, j, availElems) {
@ -750,6 +752,11 @@ static void upgradeDerivations(Globals & globals,
% i->name % bestElem->name); % i->name % bestElem->name);
newElems.push_back(*bestElem); newElems.push_back(*bestElem);
} else newElems.push_back(*i); } else newElems.push_back(*i);
} catch (Error & e) {
e.addPrefix(format("while trying to find an upgrade for `%1%':\n") % i->name);
throw;
}
} }
printMissing(globals.state, newElems); printMissing(globals.state, newElems);