🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Error Handling and Debugging: all 10 questions

Quiz: Error Handling and Debugging · Question 8 of 10

Which is the correct way to catch a rejected promise in an async function?

Which is the correct way to catch a rejected promise in an async function?

  1. A.Wrap the call in try/catch without await
  2. B.Use await inside a try block
  3. C.Use finally only
  4. D.Rejections cannot be caught
Answer & explanation

Correct answer: Use await inside a try block

await turns the rejection into a thrown error at that line, which catch receives.

Can you get the rest right without peeking?

Take the timed Quiz: Error Handling and Debugging quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →