diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index d2a270259a8cc084d7ba3a2c8e33e06c6845c11b..8f483a90daad9506c2bc2f1ebc6e844fa15b729d 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -3835,9 +3835,8 @@ void Worker::waitForInput()
     int fdMax = 0;
     for (auto & i : children) {
         for (auto & j : i.fds) {
-            if (j >= FD_SETSIZE) {
-                throw BuildError("reached FD_SETSIZE limit");
-            }
+            if (j >= FD_SETSIZE)
+                throw Error("reached FD_SETSIZE limit");
             FD_SET(j, &fds);
             if (j >= fdMax) fdMax = j + 1;
         }