3 ms·
Really? I don't follow: why is try/catch/finally preferred over: async function someAsyncThing() { startSpinner(); await asyncWork() .catch(err =
by SavantIdiot 5y ago
Really? 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?