about summary refs log tree commit diff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-01T15·19-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-01T15·19-0400
commitc770a2422a47526d5eb336af6af4292df68dad2b (patch)
tree6e31681dc8349381fa9c62d17292d322548d3d91 /src/libutil/util.cc
parent4d1b64f118cf6ebcbf530bea4a3c531704d7d6ba (diff)
Report substituter errors to clients of the Nix daemon
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 689fc543af..086574058a 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -253,7 +253,7 @@ string readLine(int fd)
             if (errno != EINTR)
                 throw SysError("reading a line");
         } else if (rd == 0)
-            throw Error("unexpected EOF reading a line");
+            throw EndOfFile("unexpected EOF reading a line");
         else {
             if (ch == '\n') return s;
             s += ch;
@@ -1015,6 +1015,13 @@ string concatStringsSep(const string & sep, const Strings & ss)
 }
 
 
+string chomp(const string & s)
+{
+    size_t i = s.find_last_not_of(" \n\r\t");
+    return i == string::npos ? "" : string(s, 0, i);
+}
+
+
 string statusToString(int status)
 {
     if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {