Arguments for or against using Try/Catch as logical operators
- by James P. Wright
I just discovered some lovely code in our companies app that uses Try-Catch blocks as logical operators.
Meaning, "do some code, if that throws this error, do this code, but if that throws this error do this 3rd thing instead".
It uses "Finally" as the "else" statement it appears.
I know that this is wrong inherently, but before I go picking a fight I was hoping for some well thought out arguments.
And hey, if you have arguments FOR the use of Try-Catch in this manner, please do tell.
EDIT
For any who are wondering, the language is C# and the code in question is about 30+ lines and is looking for specific exceptions, it is not handling ALL exceptions.