summary refs log tree commit diff
path: root/nix/libstore/derivations.cc
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-01-04 23:27:34 +0100
committerLudovic Courtès <ludo@gnu.org>2015-01-04 23:27:34 +0100
commit15ddeff532b517843668eef8f615838d15b4f75c (patch)
tree2d11b350f4a83b28cf72e3ba37cfe218ac74f868 /nix/libstore/derivations.cc
parent828c0bec6b95a6dcfffd28d0a28caecf4f69addf (diff)
downloadguix-15ddeff532b517843668eef8f615838d15b4f75c.tar.gz
Merge commit a1dd396cc02922372314c35c8035a38bfeea08df of branch 'nix'.
Diffstat (limited to 'nix/libstore/derivations.cc')
-rw-r--r--nix/libstore/derivations.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/nix/libstore/derivations.cc b/nix/libstore/derivations.cc
index d91e42784c..b452aa2caf 100644
--- a/nix/libstore/derivations.cc
+++ b/nix/libstore/derivations.cc
@@ -48,7 +48,7 @@ static Path parsePath(std::istream & str)
 {
     string s = parseString(str);
     if (s.size() == 0 || s[0] != '/')
-        throw Error(format("bad path `%1%' in derivation") % s);
+        throw FormatError(format("bad path `%1%' in derivation") % s);
     return s;
 }
 
@@ -62,7 +62,7 @@ static StringSet parseStrings(std::istream & str, bool arePaths)
 }
 
 
-Derivation parseDerivation(const string & s)
+static Derivation parseDerivation(const string & s)
 {
     Derivation drv;
     std::istringstream str(s);
@@ -112,6 +112,16 @@ Derivation parseDerivation(const string & s)
 }
 
 
+Derivation readDerivation(const Path & drvPath)
+{
+    try {
+        return parseDerivation(readFile(drvPath));
+    } catch (FormatError & e) {
+        throw Error(format("error parsing derivation `%1%': %2%") % drvPath % e.msg());
+    }
+}
+
+
 static void printString(string & res, const string & s)
 {
     res += '"';
@@ -240,7 +250,7 @@ Hash hashDerivationModulo(StoreAPI & store, Derivation drv)
         Hash h = drvHashes[i->first];
         if (h.type == htUnknown) {
             assert(store.isValidPath(i->first));
-            Derivation drv2 = parseDerivation(readFile(i->first));
+            Derivation drv2 = readDerivation(i->first);
             h = hashDerivationModulo(store, drv2);
             drvHashes[i->first] = h;
         }