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)
|
||||
{
|
||||
static char errorbuffer[1024];
|
||||
unsigned int last_error = GetLastError();
|
||||
|
||||
if (!FormatMessage(
|
||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
last_error,
|
||||
0,
|
||||
(LPTSTR) &errorbuffer,
|
||||
sizeof(errorbuffer),
|
||||
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;
|
||||
|
||||
sprintf(errorbuffer + strlen(errorbuffer), " (%08x)", last_error);
|
||||
|
||||
return errorbuffer;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user