Error handling - a best way
Hi all,
Still I'm learning C++ and I'll try my best used most better ways in my works.
When I'm coding, I mean use of try, catch or if, else etc..., always used a single line of code. Here it is...
Code:
cout << "Error. GetLastError reports " << GetLastError() << endl;
In simple word find the error code and correct way. If I'm working on MFC, cout replaced by a message box.
My question is what is the best way to display errors for users. Displaying error codes is not prefer for users. Is that a separate section in C++, handling errors/exceptions.
Re: Error handling - a best way
You can grab the error message from Windows using the FormatMessage function in conjunction with the GetLastError function..
http://msdn2.microsoft.com/en-us/lib...82(VS.85).aspx
chem
Re: Error handling - a best way
Thanks, seems it is fine. I can reuse it once write the code and test. I'll work it on at home and let you know if I got any issue.