refactor(libutil): add new constructor to SysError
using std::error_code
Change-Id: I6150d7966442551f0b6f7a0cc9739a4f9d6c4e7e
This commit is contained in:
parent
369e3f82f0
commit
95e088de72
|
@ -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 ...)
|
||||
|
|
Loading…
Reference in a new issue