Error first pattern for ES7 Async/Await
Dale Jefferson
607

Errors won’t bubble up unless you manually return them, and it becomes a unnecessary mess of you try to do that manually everywhere. Errors won’t stop the execution of the function, unless you manually handle that also.

About your example, you don’t even need multiple try catch. You can check the message property or provide custom error codes, then have if/else under catch. In real world scenarios though, many times you don’t care about the exact nature of the error, so catch will remain simple.

I think it’s unnecessary to fight something so fundamental in the language such as error handling.

Like what you read? Give Satyajit Sahoo a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.