Waverley Leung
1 min readAug 27, 2021

--

Hi Scott! You're absolutely right, great observation! Error handling with async/await relies on wrapping the await statements within a try block and then handling the errors with a subsequent catch block. One of the reasons many may choose to use async/await is that it's easier to read but it's doing the same as promise chaining.

To clarify though, .catch can only be used once at the very end and "catches" any one error that happens anywhere in any .then or try block. In other words, you can potentially have different errors happening within .then (ex: you asked for a color that doesn't exist for that shoe, the shoe isn't in stock anymore, or the worker forgot what you wanted) but .catch will only get one error. If you want to be specific about what what the error is you can manually handle errors with throw.

I hope this helps, and please let me know if I can clarify anything else!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Waverley Leung
Waverley Leung

Written by Waverley Leung

“Be present. Be open. Be kind. But speak your mind.” 🌱 Passionate about tech, connecting with people, eating good food, and dancing to my heart’s content.

Responses (1)

Write a response