2 ms·
Error-handling code is the buggiest code out there. You should strongly avoid unnecessary error-checking stuff, because how you handle it will commonly be worse
by chrismorgan 5y ago
Error-handling code is the buggiest code out there. You should strongly avoid unnecessary error-checking stuff, because how you handle it will commonly be worse than having just done nothing. As a related example, validating email addresses badly (forbidding valid email addresses) is probably worse than doing nothing (accepting invalid email addresses).
This is an excellent example of necessary error-checking stuff; user-agent feature detection (which includes the browser’s baseline functionality which is basically a completely uncontrolled third-party library, the worst situation by far) is another good example. But it’s extremely easy to take it too far. Any library stuff that gets bundled into your code, you should prefer compile-time to runtime type-checking. But anything outside, yeah, then you have to decide.