Re: Exception and GetLastError()
- From: "SvenC" <SvenC@xxxxxxxxxxxxxxxx>
- Date: Mon, 23 Jul 2007 18:00:15 +0200
Hi,
look at code blow
////////////////////
try
{
blah blah blah
}catch(...)
{
DWORD dw = GetLastError()
}
////////////////////
Does it make sence to call GetLastError() in catch block?
In my opinion, I dont think it's necesary do like above, but could sure
about it.
No, it does not make sense. Win32-APIs which use GetLastError to return error situations do not throw exceptions, so there should be no relationship between some code triggering an exception and a Win32-API trying to give you error information.
Try to avoid general catch(...)-handlers as you only blindly hide program faults. Take crashes as a chance to find the reason for the error and fix it. If you want to catch any error to do some error logging you should put a throw; at the end of the catch block so that the exception is rethrown and a debugger or DrWatson can catch an report it, e.g. as a mini dump. If you have debug symbols for all your modules you might find the cause of the error by opening such a mini dump in a debugger.
--
SvenC
.
- Prev by Date: Re: Exception and GetLastError()
- Next by Date: Re: Exception and GetLastError()
- Previous by thread: Re: Exception and GetLastError()
- Next by thread: Re: Exception and GetLastError()
- Index(es):
Relevant Pages
|