Do not use empty Catch Blocks |
Empty catch blocks are a poor design. Always output an error and use error handling in the event of an exception.
CheckId | SPC019101 |
---|---|
TypeName | DoNotUseEmptyCatchBlocks |
Severity | CriticalWarning |
Type | PowerShell File |
Bad Practice
try
{}
catch
{}
Good Practice{}
catch
{}
try
{}
catch [ExceptionTypeException]
{
Write-Debug 'An ExceptionTypeException has occurred'
}
{}
catch [ExceptionTypeException]
{
Write-Debug 'An ExceptionTypeException has occurred'
}
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.