← 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?
- A.Wrap the call in try/catch without await
- B.Use await inside a try block
- C.Use finally only
- 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 →