On Mon, 13 Sep 2004 03:24:59 -0400
"Steven T. Hatton"
C++ exception handling is, uh, interesting. Yes, you can switch out the exception handler, and you can also catch exceptions you threw from the same function, and throw them again, and again, and again......... C++ (and Java) exception handling uses a different paradigm than does C signals:
try {
code causing exceptions
.....
} catch(exception &e) {
The exception caused the code to branch here.
} ... more catch clauses
The exception handler runs in the same context as the process. In
effect, the compiler registers the catch clauses at the beginning of the
try block, so that when an exception occurs the program counter would be
adjusted to point to the handler. If no exceptions occur, the end of the
try block would cause the program to branch to the instruction following
the catch clauses. If an exception is not caught in the current context,
it is passed up the line, either terminating the program or transferring
control to a higher level try block. That way if a function throws an
exception, the stack would be unwinded to the calling function. If that
is within a try block, then the transfer would go to the appropriate
catch or further passed up the line.
--
Jerry Feldman