util/Error: add method SetLastError()
This commit is contained in:
@@ -29,6 +29,10 @@
|
|||||||
|
|
||||||
const Domain errno_domain("errno");
|
const Domain errno_domain("errno");
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
const Domain win32_domain("win32");
|
||||||
|
#endif
|
||||||
|
|
||||||
Error::~Error() {}
|
Error::~Error() {}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -112,3 +116,15 @@ Error::FormatErrno(const char *fmt, ...)
|
|||||||
|
|
||||||
SetErrno(e, buffer);
|
SetErrno(e, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
void
|
||||||
|
Error::SetLastError(const char *prefix)
|
||||||
|
{
|
||||||
|
DWORD _code = GetLastError();
|
||||||
|
const char *msg = g_win32_error_message(_code);
|
||||||
|
Format(win32_domain, int(_code), "%s: %s", prefix, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -36,6 +36,11 @@ extern const Domain errno_domain;
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define IgnoreError MPDIgnoreError
|
#define IgnoreError MPDIgnoreError
|
||||||
#undef GetMessage
|
#undef GetMessage
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Domain for GetLastError().
|
||||||
|
*/
|
||||||
|
extern const Domain win32_domain;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,6 +148,10 @@ public:
|
|||||||
void SetErrno(const char *prefix);
|
void SetErrno(const char *prefix);
|
||||||
void FormatErrno(const char *prefix, ...);
|
void FormatErrno(const char *prefix, ...);
|
||||||
void FormatErrno(int e, const char *prefix, ...);
|
void FormatErrno(int e, const char *prefix, ...);
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
void SetLastError(const char *prefix);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user