4 ms·
I've been avoiding the discussion around Dynamic/Static s/types/languages/g , documentation/interface definition, and typed exceptions. If I go off on that ran
by mey 7y ago
I've been avoiding the discussion around Dynamic/Static s/types/languages/g , documentation/interface definition, and typed exceptions. If I go off on that rant, I'll be here all day.
If you are catching error in random places, you are doing it wrong. As you pointed out, context is critical. My point is generally, the location of code that generated the error may not have sufficient context. If you have enough context locally (or through further inspection) on how to proceed, then you handle it at that level. If you don't have enough context, then you send it up the call chain.
In your code example above, if after that catch, the program exits, then I argue it is correct. Some exception that was unrecoverable happened somewhere in the application, thus it needs to halt. If the error is recoverable and the application should continue, the exception should be handled somewhere else in the application.