473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Handling exceptions in a destructor?

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

Aug 17 '05 #1
4 963
Thanks that rounds it up nicely.

Dean

Aug 17 '05 #3
"wi******@hotmail.com" <ma**********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
see http://www.parashift.com/c++-faq-lit....html#faq-17.3


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

Aug 17 '05 #4
Ian
dean wrote:
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
Aug 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Ritz, Bruno | last post by:
hi in java i found that when a method has a throws clause in the definition, callers must either handle the exceptions thrown by the method they are calling or "forward" the exception to the...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
8
by: Rahul | last post by:
Hi Everyone, I'm currently developing a class for a database, each object of the class will establish a connection to the database on a remote server and and all of this happens on the...
16
by: john6630 | last post by:
Coming from the .Net world, I am used to the try...catch...finally approach to error handling. And PHP 5 now supports this approach. But I am not clear what happens to unhandled errors/exceptioins?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.