Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling an application exception (not in a __try block) 1

Status
Not open for further replies.

Handy2005

Programmer
Apr 13, 2005
5
0
0
GB
Is this possible ? i.e to set up an all encompassing exception handling function that gets called by Windows no matter what and where an exception occurs. (so I can output some debug info of my own). Thanks.
 
Not with the "not in a try block" requirement.


You can put a try block in [tt]main[/tt].

Some test suites do that. Some even write [tt]main[/tt] for you, and you use a function called [tt]test_main[/tt] or something similar. Check out Boost.Test at for an example of such a framework that already exists.


You can, of course, create a block-local object in [tt]main[/tt], and have its destructor do something. The destructor will get called whenever the object goes out of scope, which includes when the application stops due to an uncaught exception.

You won't have access to the exception itself in the destructor, however, and it sounded like you probably wanted that.
 
Many thanks, I tried it out and it does the job for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top