Questions tagged [getlasterror]

The `GetLastError` function is part of Microsoft Windows and is part of an error-reporting mechanism used by many libraries.

The GetLastError function is part of Microsoft Windows and is part of an error-reporting mechanism used by many libraries. For more information, see GetLastError on MSDN.

88 questions
22
votes
1 answer

GetLastError(), errno, FormatMessageA() and strerror_s()?

I'm confused as to the exact relationship between GetLastError() and errno. Are they the same numerical values, or something completely different? How do I know which one I should check? And if I want to convert an error code to a string for…
Stéphane
  • 19,459
  • 24
  • 95
  • 136
12
votes
2 answers

Program exit status conventions

What is conventional return values for applications in Windows and GNU/Linux respectivly. 0 means success. But what should be used on user-requested abort. When I abort on Windows, it returns 3, but this value is not in the list of system error…
user877329
  • 6,717
  • 8
  • 46
  • 88
8
votes
1 answer

CreateFile() returns INVALID_HANDLE_VALUE but GetLastError() is ERROR_SUCCESS

I am opening a serial port using CreateFile(). I've got a testcase (too complicated to redistribute) that consistently causes CreateFile() to return INVALID_HANDLE_VALUE and GetLastError() to return ERROR_SUCCESS. By the looks of it, this bug only…
Gili
  • 86,244
  • 97
  • 390
  • 689
7
votes
1 answer

Why am I receiving 67 code from QOSStartTrackingClient method?

I am receiving error code 67 from the code below, which means ERROR_BAD_NET_NAME. Why is it happening? How can I fix it? SOCKADDR address; strcpy_s(address.sa_data, "8.8.8.8"); address.sa_family = AF_INET; if (!QOSStartTrackingClient(QoSHandle,…
Matin Lotfaliee
  • 1,745
  • 2
  • 21
  • 43
5
votes
1 answer

CreateFile() Serial Communication Issue

I am trying to do some serial communication through my usb port (named COM15), and I am getting an error. This is the code where the error is occurring: HANDLE myPortHandle = CreateFile("COM15", GENERIC_READ |…
CodeBlocks
  • 233
  • 3
  • 5
  • 14
5
votes
0 answers

GetLastError for [ARB/]WGL Errors

It seems that certain API-specific calls set the error returned by GetLastError(). For example, wglCreateContextAttribsARB(...) can return (information from the specification): ERROR_INVALID_VERSION_ARB == 0x2095 ERROR_INVALID_PROFILE_ARB ==…
geometrian
  • 14,775
  • 10
  • 56
  • 132
5
votes
1 answer

MongoDB's runCommand is much slower than direct call

I have this two mongo commands, that in my opinion should lead to the same results: for(var i=0;i<1000;i++){db.test.insert({a:1}); db.getLastError({j:1, w:1});}; for(var i=0;i<1000;i++){db.test.insert({a:1}); db.runCommand({getLastError:1, j:1,…
Tomas Kulich
  • 14,388
  • 4
  • 30
  • 35
5
votes
1 answer

mongoDB getLastError() with javascript and node.js not working

I've got a node.js application using mongoDB and I have a function that is used to drop all documents in a collection and then repopulate the collections in my db with some sample documents. I use this to test my app with known data once in a while…
Dhodgin
  • 468
  • 4
  • 8
5
votes
7 answers

Best way to pass last error to custom error redirect?

Was wondering what you thought of this solution, if this is right way to pass an error message to a custom page? In web.config: In Global.asax: