J
Jacek Dziedzic
Hi!
I'm trying to make friends with exceptions. I think I'm doing well,
there is
one thing that bothers me, however. If an object is declared within a try
block, it gets destroyed on exception, because then we're into the catch
block and out of the try block, right? How can I sense in the destructor
that we're in the middle of processing an exception (and hence take
appropriate action, like not destroying the object if some EInternalError
exception is being processed).
try {
myclass myinstance;
myinstance.DoSomethingThatCausesAnException();
}
catch(...) {
cout << "Exception" << endl;
};
myclass::~myclass() {
// take care of destroying the object, but not if we're in the middle
// of processing EInternalError, because the object is now corrupt.
// But how to find out?
};
TIA,
- J.
I'm trying to make friends with exceptions. I think I'm doing well,
there is
one thing that bothers me, however. If an object is declared within a try
block, it gets destroyed on exception, because then we're into the catch
block and out of the try block, right? How can I sense in the destructor
that we're in the middle of processing an exception (and hence take
appropriate action, like not destroying the object if some EInternalError
exception is being processed).
try {
myclass myinstance;
myinstance.DoSomethingThatCausesAnException();
}
catch(...) {
cout << "Exception" << endl;
};
myclass::~myclass() {
// take care of destroying the object, but not if we're in the middle
// of processing EInternalError, because the object is now corrupt.
// But how to find out?
};
TIA,
- J.