Neither is very good, as you're doing nothing to handle errors.
One requires .catch() in several places, the other a try { ... } catch (...) { ... } block or several.
Overall the await syntax is much easier to read and follow the logic, but if you have to put a try..catch around every one it quickly becomes a mess too.
It allows me to pipe/sidechain my errors where they truly belong, instead of breaking up my happy path logic with inline implementation of the catch block OR lambda.
If I need to abort the current function, the handler will just rethrow.
Neither is very good, as you're doing nothing to handle errors.
One requires
.catch()
in several places, the other atry { ... } catch (...) { ... }
block or several.Overall the
await
syntax is much easier to read and follow the logic, but if you have to put atry..catch
around every one it quickly becomes a mess too.I often do the following:
It allows me to pipe/sidechain my errors where they truly belong, instead of breaking up my happy path logic with inline implementation of the catch block OR lambda.
If I need to abort the current function, the handler will just rethrow.
Yeah, I agree. As with everything, you should choose carefully 😄