Everything I've read says that they should be used when something that simply "shouldn't happen" does happen. But the thing is, there's a lot of things that could go wrong.
For example, if I'm accessing an object's property via the magic __get($property)
method, it's possible that there would be no property called $property
. So does this mean that I should wrap every $foo->bar
in a try/catch?
And what about database queries? Do I really need to wrap every $stmt->execute()
in a try/catch statement?
I feel like if I wrapped everything that could go wrong in a try/catch statement, I'd end up with several dozen try/catches per file!