How catch-block selection works in exception handling
If a pill knows what to treat, could an exception also understand when to stop its journey through the stack? In application programming, a description like this is often enough, but sometimes one ...

Source: DEV Community
If a pill knows what to treat, could an exception also understand when to stop its journey through the stack? In application programming, a description like this is often enough, but sometimes one wants more details. Well, let's dive in! Last time, we looked at how exceptions are thrown and caught, as well as the connection between these two processes. We've seen functions of the __cxa* and _Unwind* families, how they intertwine, and how the compiler embeds some of them into assembly code along with additional code blocks when compiling programs. Some questions still remain unanswered. We've moved on from SjLj exceptions, and we've paused the discussion of zero-cost exceptions at the most thrilling point: the personality routine. In this article, we'll pick up right where we left off to answer the question, "How does an exception know it has reached the right catch block?" Just like last time, we'll be using the libcxx library from LLVM. We'll also use the same compiler, Clang 21.1.0 f