Merge "refactor(libutil): add new constructor to SysError using std::error_code" into main

This commit is contained in:
V.
2024-12-11 08:44:38 +00:00
committed by Gerrit Code Review
+10
View File
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <system_error>
namespace nix {
@@ -194,6 +195,15 @@ public:
err.msg = HintFmt("%1%: %2%", Uncolored(hf.str()), strerror(errNo));
}
template<typename... Args>
SysError(std::error_code ec, const Args & ... args)
: Error("")
{
errNo = ec.value();
auto hf = HintFmt(args...);
err.msg = HintFmt("%1%: %2%", Uncolored(hf.str()), ec.message());
}
template<typename... Args>
SysError(const Args & ... args)
: SysError(errno, args ...)