Bird
0
0

You want to run multiple async tasks in parallel and handle errors individually without stopping all tasks. Which pattern correctly handles errors for each async call using async/await?

hard📝 Application Q15 of 15
Node.js - Error Handling Patterns
You want to run multiple async tasks in parallel and handle errors individually without stopping all tasks. Which pattern correctly handles errors for each async call using async/await?
AWrap each await call inside its own try/catch block
BUse Promise.all with a single try/catch around it
CUse await inside a forEach loop with one try/catch outside
DIgnore errors and rely on process.on('unhandledRejection')
Step-by-Step Solution
Solution:
  1. Step 1: Understand parallel async calls and error handling

    Promise.all stops on first rejection; one try/catch around it catches all or none.
  2. Step 2: Individual error handling requires separate try/catch

    Wrapping each await in its own try/catch lets errors be handled separately without stopping others.
  3. Final Answer:

    Wrap each await call inside its own try/catch block -> Option A
  4. Quick Check:

    Individual error handling = A [OK]
Quick Trick: Try/catch each await separately for independent error handling [OK]
Common Mistakes:
  • Using Promise.all with one try/catch stops all on first error
  • Using forEach with await causes unexpected behavior
  • Ignoring errors leads to crashes or silent failures

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes