Good points:
1. No, It's not a good idea.
You can throw an exception in a destructor, but that exception must not leave the destructor; if a destructor exits by emitting an exception, all kinds of bad things are likely to happen because the basic rules of the standard library and the language itself will be violated. Don’t do it.
2. Destructor are by default noexcept.
(i.e. non-throwing, we do not expect exceptions from them, std::terminate is called in case of exception going out of destructor)
3. The Stack unwinding will happen after an exception and we may catch it outside. But don’t do it.
The C++ rule is that you must never throw an exception from a destructor that is being called during the “stack unwinding” process of another exception. For example, if someone says throw Foo(), the stack will be unwound so all the stack frames between the
and the
will get popped. This is called stack unwinding.
During stack unwinding, all the local objects in all those stack frames are destructed. If one of those destructors throws an exception (say it throws a Bar object), the C++ runtime system is in a no-win situation