util/Error: add SetLastError() overload with "DWORD code" parameter

This commit is contained in:
Max Kellermann 2014-07-30 21:59:37 +02:00
parent 32e5848f34
commit d1bc46ffad
2 changed files with 8 additions and 2 deletions

View File

@ -133,11 +133,16 @@ Error::FormatErrno(const char *fmt, ...)
#ifdef WIN32
void
Error::SetLastError(const char *prefix)
Error::SetLastError(DWORD _code, const char *prefix)
{
DWORD _code = GetLastError();
const char *msg = g_win32_error_message(_code);
Format(win32_domain, int(_code), "%s: %s", prefix, msg);
}
void
Error::SetLastError(const char *prefix)
{
SetLastError(GetLastError(), prefix);
}
#endif

View File

@ -166,6 +166,7 @@ public:
void FormatErrno(int e, const char *prefix, ...);
#ifdef WIN32
void SetLastError(DWORD _code, const char *prefix);
void SetLastError(const char *prefix);
#endif
};