Bird
0
0

Find the error in this PowerShell snippet:

medium📝 Debug Q7 of 15
PowerShell - Error Handling
Find the error in this PowerShell snippet:
try {
  throw 'Error'
} catch {
  throw
}
ASecond throw missing error message
BCannot throw inside catch block
CCatch block must have a parameter
DTry block missing finally
Step-by-Step Solution
Solution:
  1. Step 1: Review throw usage in catch

    Throw requires an error message or object; the second throw has none.
  2. Step 2: Validate catch block syntax

    Throw can be used inside catch, but must include a message or error object.
  3. Final Answer:

    Second throw missing error message -> Option A
  4. Quick Check:

    Throw needs message even in catch [OK]
Quick Trick: Throw always needs a message or object [OK]
Common Mistakes:
  • Assuming throw can be empty anywhere
  • Thinking catch block must have parameters
  • Confusing finally requirement

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes