Re: How to check from destructor whether it was called due to exception or normal exit from the scope?

From: Igor Tandetnik (itandetnik_at_mvps.org)
Date: 07/12/04


Date: Mon, 12 Jul 2004 12:07:13 -0400


"Alexander Grigoriev" <alegr@earthlink.net> wrote in message
news:ONURPcCaEHA.2296@TK2MSFTNGP10.phx.gbl
> If you want to log exceptions in critical places, write a class with a
> member function to call at the scope end. If the function was not
> called, the execution haven't reached the point, it means the
> exception was thrown. The destructor then logs a record.

This idiom is known as Scope Guard. For an extensive treatment of these,
see

http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm

-- 
With best wishes,
    Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Relevant Pages