Yes, I’m not a professional programmer but when I write code for somebody else, I’d say that at least 2/3 of it are to make it as fool proof as I’m able to. It’s a hard task to do, and a huge mental undertaking to think everything through and mend potential weaknesses or exploits.
try clause well tries all code that’s placed inside of it’s scope, and when an exception occurs and you’re trying to catch that specific exception, the
catch clause is run.
The more general the exception that you’re trying to catch, the better the chance, however this is considered bad programming, since it potentially obfuscates debugging information.
std::exception is the mother class that all other exceptions inherit from. When you try to catch it, it potentially catches all sub exceptions. I guess you see the problem here.
However, the more specific you get, the greater the chance that you don’t catch certain ones.
I’d say don’t try to catch unknown exceptions. Only use this if you’re certain what to catch.
As Menno already pointed out, you usually want to raise the exception with the
throw expression, since this also stops code execution. Outputting stuff to a console, like
RhinoApp().Print(), does just that, and then continues to run.