except: explicitly qualify win32 message table
if the mesage table isn't specified when formatting error codes some systems will fail to render the string.
This commit is contained in:
parent
fa8933673f
commit
755ba5a6a7
20
except.cpp
20
except.cpp
@ -18,6 +18,7 @@
|
|||||||
#include "./debug.hpp"
|
#include "./debug.hpp"
|
||||||
#include "./platform.hpp"
|
#include "./platform.hpp"
|
||||||
#include "./cast.hpp"
|
#include "./cast.hpp"
|
||||||
|
#include "./types.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
@ -147,16 +148,27 @@ win32_error::code_string (void)
|
|||||||
return code_string (GetLastError ());
|
return code_string (GetLastError ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
std::string
|
std::string
|
||||||
win32_error::code_string (DWORD code)
|
win32_error::code_string (DWORD code)
|
||||||
{
|
{
|
||||||
char message[256];
|
char message[256];
|
||||||
|
|
||||||
auto res = FormatMessage (0, NULL, code, 0, message, sizeof (message), NULL);
|
auto res = FormatMessage (
|
||||||
if (res == 0)
|
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
win32_error::throw_code ();
|
NULL,
|
||||||
|
code,
|
||||||
|
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
message,
|
||||||
|
elems (message),
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
return std::string (message);
|
if (res == 0) {
|
||||||
|
win32_error::throw_code ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string (message, message + res);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user