by chombier · 7y ago · 0 comments
...
if (condition1)
handle_exception1 ();
...
if (condition2)
handle_exception2 ();
...
As far as I understand, the essence of exceptions is to defer error handling to the caller, so local try/catch-es are examples of exception misuses.Of course exceptions cost a lot more on the failure path, but that's not generally the priority.
Not in the context of RAII. It helps a lot with cleanup and ensuring nothing leaks from the snippet that caused the exception if any resources were acquired.
Whereas in C you'd have to make all that cleanup manually, which can be tedious and error prone.