The Lounge is rated PG. If you're about to post something you wouldn't want your
kid sister to read then don't post it. No flame wars, no abusive conduct, no programming
questions and please don't post ads.
But I just said why I do it sometimes. It's to get a stack trace. That's a very, very useful purpose for it. It's saved my butt more times than I can count to figure out why something happened in the field. It's not at every little call along the way, but the important points that let me know where something was happening.
Otherwise I am using exception safe programming. Well, almost all of the time. There are exceptions to every rule sometimes. You aren't always dealing purely in a C++ world if you write low level code.
Exception handling is not something that can be done generically. Especially at the 'Exception' level.
In certain cases one might generalize exception handling but only within the limits of some specific idiom. For example a specific inheritance model might provide a generic handler in the base class, but even then it should be considered as a convenience rather than as an absolute.
And generalizing logging is not going to work either. For example for DB api calls logging a primary id might be a good idea, while with a web API call logging the url is probably needed. There are a lot of variations even within those.
Not to mention that logging libraries seem to provide calls that support general purpose logging including exceptions so that would seem to do what that code does.
Far as I know the above would be true for all languages that throw exceptions. It is true for java, c# and c++.
Anything wrong with you adding the necessary exception name, recompiling and running the example again in your debugger. The only problem I can think of is if your code take 3 hours to compile (like one codebase I worked on )