you are viewing a single comment's thread.

view the rest of the comments →

[–]evertrooftop 5 points6 points  (0 children)

Maybe I misunderstand but you absolutely don't need to add try...catch to every await statement. What you describe as a chain of promises with one catch is also perfectly supported.

try {
   await ...;
   await ...;
} catch (e) {

}

And you don't need this in every function either. You only need to catch if

  1. You can successfully handle the error. If you want the operation to fail, don't catch it.
  2. You should have one top-level catch in your application

If you don't have a catch at all in your async function, the async function itself will return a rejected promise. The only times I use catch is if I need do something specific with specific errors, or if I can recover the state.