Re: Try/Catch
- Posted by DerekParnell (admin) Jan 08, 2015
- 5741 views
By your definition above, I'd argue that these aren't really exceptions - errors, sure, but they're reasonably anticipatible and should be detectable and correctable with an appropriate amount of testing.
How does one know? I certainly do not know what actually triggers the exceptions in these examples. I know the message displayed, but not the underlying cause.
But my issue is that if we rely on recoverability code, then we may be unpleasantly surprised when we happen across situations that cannot be always be recovered.
And I didn't even mention what we might try when exceptions happen during the execution of the recovery code.
What we need is a compelling argument for why recovery should be an option after an exception occurs - and what exactly do we mean by recovery?
Are you talking about after a true exception occurs, or a not-exception like your examples? The difference is important.
I said, quite explicitly, that the examples are exceptions, in the sense that the coder used the try-catch paradigm. It actually doesn't matter if they are errors or exceptions, because I was trying to focus on the idea of recover from when things go pear-shaped.