RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: C++
Expertise: Intermediate
May 8, 1999

Unwinding the Stack

When an exception is thrown, the runtime mechanism first searches for an appropriate handler (a catch statement) for it in the current scope. If such a handler does not exist, the current scope is exited and the function that is higher in the calling chain is entered into scope. This process is iterative; it continues until an appropriate handler has been found. An exception is considered to be handled upon its entry to a handler. At this point, all the local objects that were constructed on the path from a try block to a throw-expression have been destroyed. In other words, the stack has been unwound.
Danny Kalev
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date