Re: Exception and GetLastError()
- From: "SvenC" <SvenC@xxxxxxxxxxxxxxxx>
- Date: Mon, 23 Jul 2007 18:42:45 +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.
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.
mimi dump?
Could you please give a sample about this?
Take a look at http://www.microsoft.com/whdc/devtools/debugging/default.mspx to get information about the debugging SDK.
Mini dumps are snap shots of parts of a processes memory, like the call stacks of the current threads and maybe also parts of the heap.
DrWatson does write those dumps. Use drwtsn32 -i to set it as debugger and drwtsn32 to configure some parameters like which directory to use to write the dump files to.
Those dump files (usually with an extension of dmp, mdmp, udmp or hdmp) can be loaded with windbg from the debugging sdk so that you can analyze the state of a process when an exception occurs.
You can also use MiniDumpWriteDump to create dump files programmatically. It is alos describer in the debugging SDK.
Those dumps depend heavily on debug symbols, so be sure to create all modules (dll, ocx and exes) with debugging symbols (pdb files). Microsoft provides them with their public symbol server (also described in the debugging sdk).
--
SvenC
.
- References:
- Re: Exception and GetLastError()
- From: SvenC
- Re: Exception and GetLastError()
- Prev by Date: Re: Exception and GetLastError()
- Next by Date: Re: multi-process singleton DLL
- Previous by thread: Re: Exception and GetLastError()
- Next by thread: Re: Exception and GetLastError()
- Index(es):
Relevant Pages
|