DEV Community

Discussion on: Error handling with async/await and promises

 
tunaxor profile image
Angel Daniel Munoz Gonzalez

The repl shows you manually throwing in catch() in order to skip the remaining then()s as well as manually returning the data, neither of which seem like a practice

Promises are meant to be used in a "synchronous way" because once code becomes async it can't go back to be sync, so passing stuff around is what they are meant to do.
I updated the repl throwing synchronous and asynchronously just comment and uncomment 11 and 10, 17 (which is the synchronous code that will throw synchronously inside a catch) to see what I mean.

It's nice to see different perspectives, cheers!