3 ms·
The core of the post: try/catch, which blurs the line between errors that are *mistakes* (accessing a property of null, calling .write() on a stream afte
by perfunctory 15y ago
The core of the post:
try/catch, which blurs the line between errors
that are *mistakes* (accessing a property of null,
calling .write() on a stream after .end(), etc.),
and those which are expected application-level problems
(invalid data, file missing, and so on).
Totally agree.
- morsch 15y agoIn a typed exception system, you just assign different kinds of exceptions to all of those. Java also distinguishes between checked exceptions ("known unknowns") which need to be declared, and runtime exceptions ("unknown unknowns"). Sure, you can still catch all of them in one place, but that's very rarely a good idea. A non-typed exception system (that doesn't solve the problem with another mechanism) just sounds like a very bad idea. Is Javascript like that?
- thomasz 15y agoIt totally depends on your Application. I wouldn't call a non existing file referenced by a db record, an strange log entry or a malformed xml returned by a webservice an "expected application-level problem". There is absolutely no way for a library writer to decide between an expected and an exceptional condition.