about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.cc2
-rw-r--r--src/libutil/util.hh11
2 files changed, 11 insertions, 2 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 2998506b5821..e2f5b087f13f 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -927,7 +927,7 @@ string runProgram(Path program, bool searchPath, const Strings & args,
     /* Wait for the child to finish. */
     int status = pid.wait(true);
     if (!statusOk(status))
-        throw ExecError(format("program ‘%1%’ %2%")
+        throw ExecError(status, format("program ‘%1%’ %2%")
             % program % statusToString(status));
 
     return result;
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 1a43bf400a03..259c73260da3 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -247,7 +247,16 @@ pid_t startProcess(std::function<void()> fun, const ProcessOptions & options = P
 string runProgram(Path program, bool searchPath = false,
     const Strings & args = Strings(), const string & input = "");
 
-MakeError(ExecError, Error)
+class ExecError : public Error
+{
+public:
+    int status;
+
+    template<typename... Args>
+    ExecError(int status, Args... args)
+        : Error(args...), status(status)
+    { }
+};
 
 /* Convert a list of strings to a null-terminated vector of char
    *'s. The result must not be accessed beyond the lifetime of the