3 ms·
There are errors, and there are errors. The kind of error that you'd handle high up the stack is, say, a general I/O error reading a file. But when you look u
by int_19h 10y ago
There are errors, and there are errors.
The kind of error that you'd handle high up the stack is, say, a general I/O error reading a file.
But when you look up an item in a collection (or a node in a DOM tree), and it is not found, the only place where you can sensibly handle that is right where the lookup happens, usually.
In a language that doesn't follow this philosophy, what you get instead are random NullPointerExceptions etc. If you go and look at a random C# or Java project on GitHub and check its tracker, you will see that - surprise, surprise! - that is exactly the type of error that shows up most.
- barrkel 10y agoNull pointer exceptions are programming errors. They're usually better handled up the stack too. An item not found in a collection or tree is not an error.
- int_19h 10y agoHow exactly do you handle a null pointer exception?
- barrkel 10y agoProgramming errors in production are usually handled by logging and then either exiting the process or going back around the request / response loop again (presuming global state hasn't been polluted, which is unusual in most modern application servers since they're usually stateless). Null pointer exceptions are little different.