Bird
0
0

Find the mistake in this Promise error handling:

medium📝 Debug Q7 of 15
Node.js - Error Handling Patterns
Find the mistake in this Promise error handling:
fetchData()
  .then(data => process(data))
  .catch(() => console.log('Error:', error));
AUsing then before catch is invalid.
Bprocess should be inside catch, not then.
CMissing error parameter in catch callback.
DConsole.log syntax is incorrect.
Step-by-Step Solution
Solution:
  1. Step 1: Check catch callback parameters

    The catch callback must declare an error parameter to access the error object.
  2. Step 2: Analyze catch usage

    Here, catch uses error variable without declaring it, causing ReferenceError.
  3. Final Answer:

    Missing error parameter in catch callback. -> Option C
  4. Quick Check:

    Always declare error parameter in catch callback [OK]
Quick Trick: Declare error parameter in catch to access error info [OK]
Common Mistakes:
  • Using error variable without declaration
  • Thinking catch runs without error parameter
  • Confusing then and catch parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes