2 ms·
Spot the Howler: "it’s always best to catch an exception as close to the throw point as possible". No. It's fastest to do that, but if you cared about fast, yo
by ncmncm 7y ago
Spot the Howler: "it’s always best to catch an exception as close to the throw point as possible".
No. It's fastest to do that, but if you cared about fast, you wouldn't be throwing at all.
Exceptions, by definition, are off of the critical path. If there's a generalization to be made, it's that it's always best to catch them as far from the event as possible, because then you will have few catch clauses. If you have more than a few, you are Doing It Wrong.
It shows a fundamental misunderstanding to worry about how fast throwing an exception is. You legitimately worry about how fast it is not to throw them, and that is generally quite fast indeed.