From 2d4d26769d6a3be1b21302b0bb2bd099fd55ccf8 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 17 Dec 2022 12:25:47 +0100 Subject: daemon: Make "opening file" error messages distinguishable. * nix/libstore/build.cc (DerivationGoal::openLogFile): Customize "opening file" error message. * nix/libutil/hash.cc (hashFile): Likewise. * nix/libutil/util.cc (readFile, writeFile): Likewise. --- nix/libutil/hash.cc | 2 +- nix/libutil/util.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'nix/libutil') diff --git a/nix/libutil/hash.cc b/nix/libutil/hash.cc index 7853acdd49..9ba604eb85 100644 --- a/nix/libutil/hash.cc +++ b/nix/libutil/hash.cc @@ -244,7 +244,7 @@ Hash hashFile(HashType ht, const Path & path) start(ht, ctx); AutoCloseFD fd = open(path.c_str(), O_RDONLY); - if (fd == -1) throw SysError(format("opening file `%1%'") % path); + if (fd == -1) throw SysError(format("computing hash of file `%1%'") % path); unsigned char buf[8192]; ssize_t n; diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc index 4d3780e3c2..82eac72120 100644 --- a/nix/libutil/util.cc +++ b/nix/libutil/util.cc @@ -264,7 +264,7 @@ string readFile(const Path & path, bool drain) { AutoCloseFD fd = open(path.c_str(), O_RDONLY); if (fd == -1) - throw SysError(format("opening file `%1%'") % path); + throw SysError(format("reading file `%1%'") % path); return drain ? drainFD(fd) : readFile(fd); } @@ -273,7 +273,7 @@ void writeFile(const Path & path, const string & s) { AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0666); if (fd == -1) - throw SysError(format("opening file '%1%'") % path); + throw SysError(format("writing file '%1%'") % path); writeFull(fd, s); } -- cgit v1.2.3