4 ms·
> With async/await you have to wrap everything in try/catch, so it only looks better if you do not handle errors. Better than having if (err) { call
by pitaj 8y ago
> With async/await you have to wrap everything in try/catch, so it only looks better if you do not handle errors.
Better than having
if (err) {
callback(err);
return;
}
at the top of every function.
> It also makes it harder to do more advanced designs like rate limiting, loading bars, etc.
No it doesn't. Rate limiting is no harder with Promises or async/await. Loading bars can be handled with async iterators. At the worst, one only needs to fall back to callbacks in such situations, and abstract that in a Promise wrapper for use with async/await.
> I really like callback convention with error first.
It has completely different semantics from the rest of the language. You must handle an error wherever it's thrown, which is ridiculous.
> The most important part of async code is error handling.
Sure, and that handling should be done at the highest level possible.