about summary refs log tree commit diff
path: root/src/nix-daemon/nix-daemon.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-02T12·34+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-02T12·34+0200
commit28e0742966e962f2672f5731ea3612f223bf3283 (patch)
treeedb6e9830ef95ad987fbae1611a9b31752f1eda8 /src/nix-daemon/nix-daemon.cc
parenta5fb4b5b7c1688c9b095bc1c278c17c20844302a (diff)
Report OOM errors better
Diffstat (limited to 'src/nix-daemon/nix-daemon.cc')
-rw-r--r--src/nix-daemon/nix-daemon.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index 19b72f7eae45..58ef2109b313 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -731,6 +731,10 @@ static void processConnection(bool trusted)
             if (!errorAllowed) printMsg(lvlError, format("error processing client input: %1%") % e.msg());
             stopWork(false, e.msg(), GET_PROTOCOL_MINOR(clientVersion) >= 8 ? e.status : 0);
             if (!errorAllowed) break;
+        } catch (std::bad_alloc & e) {
+            if (canSendStderr)
+                stopWork(false, "Nix daemon out of memory", GET_PROTOCOL_MINOR(clientVersion) >= 8 ? 1 : 0);
+            throw;
         }
 
         to.flush();
@@ -893,7 +897,7 @@ static void daemonLoop()
                     processConnection(trusted);
 
                 } catch (std::exception & e) {
-                    writeToStderr("child error: " + string(e.what()) + "\n");
+                    writeToStderr("unexpected Nix daemon error: " + string(e.what()) + "\n");
                 }
                 exit(0);
             }