Bird
0
0

Identify the issue in this try-catch block:

medium📝 Debug Q6 of 15
Node.js - Error Handling Patterns
Identify the issue in this try-catch block:
try {
  console.log('Test');
} catch {
  console.log('Error caught');
}
AMissing error parameter in catch block
Btry block cannot have console.log
Ccatch block must be empty
DNo issues; code is valid
Step-by-Step Solution
Solution:
  1. Step 1: Check catch syntax

    In Node.js, catch must include an error parameter to capture exceptions.
  2. Step 2: Analyze code

    Catch block is missing the error parameter, which causes syntax error.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Catch requires error parameter in Node.js [OK]
Quick Trick: Always include error parameter in catch block [OK]
Common Mistakes:
  • Omitting error parameter in catch
  • Assuming catch can be empty parentheses
  • Confusing catch with finally

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes