hw/xwin/glx: Improvements to glxWinErrorMessage() reporting in WGL GLX provider
Request the message using languageID 0 (best effort), rather than only using language neutral messages Always report the numeric error code. Trim any trailing \r from FormatMessage() output Reviewed-by: Colin Harrison <colin.harrison@virgin.net> Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
This commit is contained in:
parent
3873be16d0
commit
eecc8e06eb
|
@ -211,22 +211,25 @@ static
|
||||||
const char *glxWinErrorMessage(void)
|
const char *glxWinErrorMessage(void)
|
||||||
{
|
{
|
||||||
static char errorbuffer[1024];
|
static char errorbuffer[1024];
|
||||||
|
unsigned int last_error = GetLastError();
|
||||||
|
|
||||||
if (!FormatMessage(
|
if (!FormatMessage(
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||||
NULL,
|
NULL,
|
||||||
GetLastError(),
|
last_error,
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
0,
|
||||||
(LPTSTR) &errorbuffer,
|
(LPTSTR) &errorbuffer,
|
||||||
sizeof(errorbuffer),
|
sizeof(errorbuffer),
|
||||||
NULL ))
|
NULL ))
|
||||||
{
|
{
|
||||||
snprintf(errorbuffer, sizeof(errorbuffer), "Unknown error in FormatMessage: %08x!", (unsigned)GetLastError());
|
snprintf(errorbuffer, sizeof(errorbuffer), "Unknown error");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errorbuffer[strlen(errorbuffer)-1] == '\n')
|
if ((errorbuffer[strlen(errorbuffer)-1] == '\n') || (errorbuffer[strlen(errorbuffer)-1] == '\r'))
|
||||||
errorbuffer[strlen(errorbuffer)-1] = 0;
|
errorbuffer[strlen(errorbuffer)-1] = 0;
|
||||||
|
|
||||||
|
sprintf(errorbuffer + strlen(errorbuffer), " (%08x)", last_error);
|
||||||
|
|
||||||
return errorbuffer;
|
return errorbuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue