2 ms·
I think a good rule is that if you're not planning (or able) to confidently deal with an exception and put the app into a known state, then don't catch it. Som
by jakejake 15y ago
I think a good rule is that if you're not planning (or able) to confidently deal with an exception and put the app into a known state, then don't catch it.
Some developers seem to have a fear of allowing any errors to be seen by the user and so they have a habit of swallowing exceptions. I guess it makes them feel that the code is more stable, but it actually masks bugs and makes them impossible to troubleshoot. I have a name for these - I call them "insidious bugs" especially when they result in data loss, which is common with those types of bugs.
I was just in some code the other day that was littered with a bunch of these:
try {
... code here ...
}
catch(e) {}
not even a console statement or anything! It took two of us over 6 hours chasing down what should have been a 15 minute bug due to that code.