diff --git a/lix/libutil/error.hh b/lix/libutil/error.hh index 451319494..a81f3f9cd 100644 --- a/lix/libutil/error.hh +++ b/lix/libutil/error.hh @@ -26,6 +26,7 @@ #include #include #include +#include namespace nix { @@ -194,6 +195,15 @@ public: err.msg = HintFmt("%1%: %2%", Uncolored(hf.str()), strerror(errNo)); } + template + 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 SysError(const Args & ... args) : SysError(errno, args ...)