3 ms·
Totally agree, I do the same, up to and including having a chat with a coworker who wrote code like that. I just did that last week, in fact. Code that uses e
by olvy0 5y ago
Totally agree, I do the same, up to and including having a chat with a coworker who wrote code like that. I just did that last week, in fact.
Code that uses exceptions like this is a code smell, especially when performance is important. Using exceptions as control flow instead of if/loops is not a good design, IMO.
Note that this is in C++. I consider this style of writing not idiomatic, despite the STL doing it. I use either error return codes or std::optional (itself having a set of problems but IMO better than exceptions).
I'm more willing to accept this kind of code in Java, where it's more or less idiomatic. Less so in C#, where the tendency in the last 15 years has been to use the Try__ method instead of throwing exceptions.