aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-09-21 16:00:03 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-09-21 16:54:53 +0200
commit4036185cb4bacbf6acaaa1a906924dfa2cdd9413 (patch)
treeb7169ae0d7a120e433dcecbd20333f0dbd1e8f8a /src/libutil/util.cc
parent3f8e620b1907968c47bdbe955095301159dc78ad (diff)
Some notational convenience for formatting strings
We can now write throw Error("file '%s' not found", path); instead of throw Error(format("file '%s' not found") % path); and similarly printError("file '%s' not found", path); instead of printMsg(lvlError, format("file '%s' not found") % path);
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 68311a3df..ce54350d7 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -31,13 +31,6 @@ extern char * * environ;
namespace nix {
-BaseError::BaseError(const FormatOrString & fs, unsigned int status)
- : status(status)
-{
- err = fs.s;
-}
-
-
BaseError & BaseError::addPrefix(const FormatOrString & fs)
{
prefix_ = fs.s + prefix_;
@@ -45,10 +38,10 @@ BaseError & BaseError::addPrefix(const FormatOrString & fs)
}
-SysError::SysError(const FormatOrString & fs)
- : Error(format("%1%: %2%") % fs.s % strerror(errno))
- , errNo(errno)
+std::string SysError::addErrno(const std::string & s)
{
+ errNo = errno;
+ return s + ": " + strerror(errNo);
}