Why can catch miss an error?
Documentation: Microsoft Learn
catch only catches terminating errors — check you know why some errors slip through.
Overview
QUIZ
Core PowerShell · Question 8 of 12
Explanation
Many cmdlets emit non-terminating errors unless you use ErrorAction Stop or another appropriate strategy.
Apply the reasoning
A catch block handles terminating errors from the try block. Many cmdlets report a non-terminating error and continue processing other input. ErrorAction Stop can promote that cmdlet error so the catch block can handle it.
Why the other choices fail
Runtime errors can be caught; a parse failure in the script itself occurs before that script can run its try block. The error stream is separate from success output. Formatting does not control exception behavior, and try does not suppress errors. Test the failure path deliberately and preserve enough error information to diagnose the real cause.
Review the prerequisite
Read this first:
Primary documentation
Choose your answer
Choose one answer to see feedback.