Handling exceptions in a destructor?

D

dean

What's the generally accepted way to handle an exception in a
destructor? We just found out the hard way that throwing an exception
is not going to work.

-Dean
 
?

=?iso-8859-1?Q?Ali_=C7ehreli?=


Unfortunately the FAQ misses an important point.

It is not "not to throw" but "not to escape" exceptions from destructors. A
guideline from Exceptional C++ by Herb Sutter:

<quote>
Never allow an exception to escape from a destructor or from
an overloaded operator delete() or operator delete[]();
write every destructor and deallocation function as though it
had an exception specification of "throw()."
</quote>

Ali
 
I

Ian

dean said:
What's the generally accepted way to handle an exception in a
destructor? We just found out the hard way that throwing an exception
is not going to work.
Catch them and either ignore them, log something or assert, depending on
where you are in development and your policies.

Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top