Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libexpr/include/nix/expr/value/context.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public:
std::string_view raw;

template<typename... Args>
BadNixStringContextElem(std::string_view raw_, const Args &... args)
BadNixStringContextElem(std::string_view raw_, Args &&... args)
: CloneableError("")
{
raw = raw_;
auto hf = HintFmt(args...);
auto hf = HintFmt(std::forward<Args>(args)...);
err.msg = HintFmt("Bad String Context element: %1%: %2%", Uncolored(hf.str()), raw);
}
};
Expand Down
10 changes: 3 additions & 7 deletions src/libstore/filetransfer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1446,20 +1446,16 @@ void FileTransfer::download(
void FileTransferError::anchor() {}

template<typename... Args>
FileTransferError::FileTransferError(
FileTransfer::Error error, std::optional<std::string> response, const Args &... args)
: CloneableError(args...)
FileTransferError::FileTransferError(FileTransfer::Error error, std::optional<std::string> response, Args &&... args)
: CloneableError(HintFmt(std::forward<Args>(args)...))
, error(error)
, response(response)
{
const auto hf = HintFmt(args...);
// FIXME: Due to https://github.com/NixOS/nix/issues/3841 we don't know how
// to print different messages for different verbosity levels. For now
// we add some heuristics for detecting when we want to show the response.
if (response && (response->size() < 1024 || response->find("<html>") != std::string::npos))
err.msg = HintFmt("%1%\n\nresponse body:\n\n%2%", Uncolored(hf.str()), chomp(*response));
else
err.msg = hf;
err.msg = HintFmt("%1%\n\nresponse body:\n\n%2%", Uncolored(err.msg.str()), chomp(*response));
}

} // namespace nix
4 changes: 2 additions & 2 deletions src/libstore/include/nix/store/build-result.hh
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public:
* Delegates to the string constructor after formatting.
*/
template<typename... Args>
BuildError(Status status, const Args &... args)
: CloneableError(args...)
BuildError(Status status, Args &&... args)
: CloneableError(std::forward<Args>(args)...)
, status{status}
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/include/nix/store/filetransfer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public:
std::optional<std::string> response;

template<typename... Args>
FileTransferError(FileTransfer::Error error, std::optional<std::string> response, const Args &... args);
FileTransferError(FileTransfer::Error error, std::optional<std::string> response, Args &&... args);
};

} // namespace nix
8 changes: 4 additions & 4 deletions src/libstore/include/nix/store/sqlite.hh
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ class SQLiteError : public CloneableError<SQLiteError, Error>

public:
template<typename... Args>
[[noreturn]] static void throw_(sqlite3 * db, const std::string & fs, const Args &... args)
[[noreturn]] static void throw_(sqlite3 * db, const std::string & fs, Args &&... args)
{
throw_(db, HintFmt(fs, args...));
throw_(db, HintFmt(fs, std::forward<Args>(args)...));
}

SQLiteError(const char * path, const char * errMsg, int errNo, int extendedErrNo, int offset, HintFmt && hf);
Expand All @@ -193,8 +193,8 @@ protected:
int extendedErrNo,
int offset,
const std::string & fs,
const Args &... args)
: SQLiteError(path, errMsg, errNo, extendedErrNo, offset, HintFmt(fs, args...))
Args &&... args)
: SQLiteError(path, errMsg, errNo, extendedErrNo, offset, HintFmt(fs, std::forward<Args>(args)...))
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/libstore/windows/pathlocks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ AutoCloseFD openLockFile(const std::filesystem::path & path, bool create)
* Wine has incomplete file locking support, so we degrade gracefully.
*/
template<typename... Args>
static bool warnOrThrowWine(DWORD lastError, const std::string & fs, const Args &... args)
static bool warnOrThrowWine(DWORD lastError, const std::string & fs, Args &&... args)
{
using namespace nix::windows;
if (isWine()) {
warn(fs + ": %s (ignored under Wine)", args..., lastError);
return true;
}
throw WinError(lastError, fs, args...);
throw WinError(lastError, fs, std::forward<Args>(args)...);
}

bool lockFile(Descriptor desc, LockType lockType, bool wait)
Expand Down
4 changes: 2 additions & 2 deletions src/libutil/archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ void dumpString(std::string_view s, Sink & sink)
}

template<typename... Args>
static SerialisationError badArchive(std::string_view s, const Args &... args)
static SerialisationError badArchive(std::string_view s, Args &&... args)
{
return SerialisationError("bad archive: " + s, args...);
return SerialisationError("bad archive: " + s, std::forward<Args>(args)...);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems pretty cursed that we dynamically construct the format string here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that's pre-existing, so meh

}

static void parseContents(CreateRegularFileSink & sink, Source & source)
Expand Down
4 changes: 2 additions & 2 deletions src/libutil/include/nix/util/processes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ public:
int status;

template<typename... Args>
ExecError(int status, const Args &... args)
: CloneableError(args...)
ExecError(int status, Args &&... args)
: CloneableError(std::forward<Args>(args)...)
, status(status)
{
}
Expand Down
Loading