Error first pattern for ES7 async / await
Dale Jefferson
257

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.

Show your support

Clapping shows how much you appreciated Satyajit Sahoo’s story.