diff --git a/lix/libstore/filetransfer.cc b/lix/libstore/filetransfer.cc index 4d1856667..a8a1098a8 100644 --- a/lix/libstore/filetransfer.cc +++ b/lix/libstore/filetransfer.cc @@ -1321,18 +1321,4 @@ ref makeFileTransfer(std::optional baseRetryTimeMs) return makeCurlFileTransfer(baseRetryTimeMs); } -template -FileTransferError::FileTransferError(FileTransfer::Error error, std::optional response, const Args & ... args) - : Error(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("") != std::string::npos)) - err.msg = HintFmt("%1%\n\nresponse body:\n\n%2%", Uncolored(hf.str()), chomp(*response)); - else - err.msg = hf; -} - } diff --git a/lix/libstore/filetransfer.hh b/lix/libstore/filetransfer.hh index f01adb994..aeb5d7e0b 100644 --- a/lix/libstore/filetransfer.hh +++ b/lix/libstore/filetransfer.hh @@ -3,12 +3,13 @@ #include "lix/libutil/async-io.hh" #include "lix/libutil/box_ptr.hh" -#include "lix/libutil/ref.hh" +#include "lix/libutil/config.hh" #include "lix/libutil/logging.hh" +#include "lix/libutil/ref.hh" #include "lix/libutil/result.hh" #include "lix/libutil/serialise.hh" +#include "lix/libutil/strings.hh" #include "lix/libutil/types.hh" -#include "lix/libutil/config.hh" #include #include @@ -118,7 +119,18 @@ public: std::optional response; template - FileTransferError(FileTransfer::Error error, std::optional response, const Args & ... args); + FileTransferError(FileTransfer::Error error, std::optional response, const Args & ... args) + : Error(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("") != std::string::npos)) + err.msg = HintFmt("%1%\n\nresponse body:\n\n%2%", Uncolored(hf.str()), chomp(*response)); + else + err.msg = hf; + } }; }