Is there any section in c++ for which we can not handle exceptions?
3 Answers
You can throw an exception of your own and handle it. Are you trying to say places like constructors destructor in which case you can refer the following http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.2
Can you be more specific. What exactly are you looking for.
-
any pre/user defined function or variables for which we can not handle exception Commented Jun 21, 2010 at 8:32
-
1@lalmay-j, what exactly do you mean by "can not handle exception"? Please add this clarification as an update to your original question, and remove this comment. SO is not working like a discussion forum. Commented Jun 21, 2010 at 8:35
well the destructor must never throw and you must not use exception in signal handlers because that almost always doesn't end well if that's what your asking but your question is a bit vague.
-
2More like the destructor shouldn't throw, but it's perfectly fine to. I think the question isn't about should but about require. Commented Jun 21, 2010 at 9:07
-
1Same thing about signal handlers - they should not exit by exception, but it is acceptable to throw&catch in them.– MSaltersCommented Jun 21, 2010 at 9:47
There is only one situation where an exception handler cannot handle an exception - a function try/catch block around a constructor.
The catch block(s) can translate the exception caught, but they cannot exit without throwing. See here for a more complete discussion.
If you were asking about places from where exceptions cannot be thrown instead of where they cannot be handled then...
Throwing an exception fro a destructor is extremely ill advised. The circumstances under which it is safe are so hard to guarantee that you should just avoid ever throwing from a destructor.