3 ms·
Giant post about the nightmare that is making robust code in node.js. Summary, don't use a language in large projects that makes it so easy to leak errors and e
by hueving 10y ago
Giant post about the nightmare that is making robust code in node.js. Summary, don't use a language in large projects that makes it so easy to leak errors and exceptions. There's something to be said about the compiler forcing you to declare what exceptions your code can throw to force you to think about this stuff up front.
- Illniyar 10y agoNot really, just normal error handling issues like most other languages. You should always know how the api you are using returns an error and use it - most langauges have multiple common ways of notifying of an error. As to leaking, coming from Java's terrible error handling, you just start using runtime errors all the time anyway, at least with js the result is more concise.
- kbart 10y agoWhat better alternatives do you know? I don't know any programming language for real world projects that would make error handling trivial.
- wyager 10y agoTrivial? No. But you can at least make it better than the horrible nightmare described in the OP. Monadic error handling in a strongly typed language gives you a huge leg up on safely and sanely managing the complexity of error handling, because it provides simple value-level error semantics and clear type-level indications of exactly what kinds of errors you have to deal with and how you have to deal with them.
- ralusek 10y agoNode is actually best used with Promises, which aren't even mentioned in this post. Promises, aside from being far more concise with a huge amount of utility, do not leak errors or exceptions. doAMillionThings() .catch((err) => handleAnything(err));