aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libstore/filetransfer.cc12
-rw-r--r--src/libstore/filetransfer.hh7
-rw-r--r--src/libutil/error.hh3
3 files changed, 17 insertions, 5 deletions
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc
index d89f8388f..fa8ad33f5 100644
--- a/src/libstore/filetransfer.cc
+++ b/src/libstore/filetransfer.cc
@@ -834,6 +834,18 @@ void FileTransfer::download(FileTransferRequest && request, Sink & sink)
}
}
+template<typename... Args>
+FileTransferError::FileTransferError(FileTransfer::Error error, std::shared_ptr<string> response, const Args & ... args)
+ : Error(args...), error(error), response(response)
+{
+ const auto hf = hintfmt(args...);
+ if (response) {
+ err.hint = hintfmt("%1%\n\nresponse body:\n\n%2%", normaltxt(hf.str()), response);
+ } else {
+ err.hint = hf;
+ }
+}
+
bool isUri(const string & s)
{
if (s.compare(0, 8, "channel:") == 0) return true;
diff --git a/src/libstore/filetransfer.hh b/src/libstore/filetransfer.hh
index 8e31a9e42..25ade0add 100644
--- a/src/libstore/filetransfer.hh
+++ b/src/libstore/filetransfer.hh
@@ -104,10 +104,11 @@ class FileTransferError : public Error
public:
FileTransfer::Error error;
std::shared_ptr<string> response; // intentionally optional
+
template<typename... Args>
- FileTransferError(FileTransfer::Error error, std::shared_ptr<string> response, const Args & ... args)
- : Error(args...), error(error), response(response)
- { }
+ FileTransferError(FileTransfer::Error error, std::shared_ptr<string> response, const Args & ... args);
+
+ virtual const char* sname() const override { return "FileTransferError"; }
};
bool isUri(const string & s);
diff --git a/src/libutil/error.hh b/src/libutil/error.hh
index 1e6102ce1..ac9d2e494 100644
--- a/src/libutil/error.hh
+++ b/src/libutil/error.hh
@@ -173,9 +173,8 @@ public:
template<typename... Args>
SysError(const Args & ... args)
- :Error("")
+ : Error(""), errNo(errno)
{
- errNo = errno;
auto hf = hintfmt(args...);
err.hint = hintfmt("%1%: %2%", normaltxt(hf.str()), strerror(errNo));
}