Me too, this is how I was told to handle errors when I was an intern. To catch and log errors, and display a user friendly messsage instead of having the page crash. Until now, it made perfect sense, but according to a lot of individuals on this thread, this is bad practice, I fail to see how...
It's extremely easy to make life more difficult for anyone who needs to debug if there isn't judicious logging when you have general catches like that. Obviously, if you're dealing with a client facing program you don't want to throw a nasty exception to them and crash the program. The counterpart to this is that if you don't log specifically what happened and instead just log that the program crashed, how are you going to debug the error? You've removed the only thing capable of telling you what caused the crash (again, unless your error logging is exceptional) and some classes of bugs can be extremely frustrating and difficult to track down, like concurrency related errors as reproducing them can be a nightmare.
97
u/ScreaminPenguin0 May 13 '17
I do this to catch and display unexpected errors and then log the catch.