6 ms·
Nope. It was designed precisely for patterns like this.
by jaffathecake 5y ago
Nope. It was designed precisely for patterns like this.
- SavantIdiot 5y agoReally? I don't follow: why is try/catch/finally preferred over: async function someAsyncThing() { startSpinner(); await asyncWork() .catch(err => { if (err.name == 'AbortError') return; showErrorUI(); }) .finally(() => { stopSpinner(); }); } Should be identical, no? EDIT: Well, except that if there was more after asyncWork() the return in the try block would exit someAsyncThing, whereas the return in the catch block just returns from the catch. Is that his point?