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.
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 )
Pretty much along similar lines.
Why do people still put their names / e-mails / former places of employment etc. in preamble of published software text after intentionally or "accidentally" removing all comments / functions descriptions etc ?
Last Visit: 20-Aug-19 7:05 Last Update: 20-Aug-19 7:05