Skip to main content
powershell/PSAvoidUsingEmptyCatchBlock is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.

Description

Empty catch blocks are considered a poor design choice because any errors occurring in a try block cannot be handled.

How

Use Write-Error or throw statements within the catch block.

Examples

Problematic code

Correct code

Source

This rule documentation is adapted from Microsoft’s PSScriptAnalyzer documentation for AvoidUsingEmptyCatchBlock, licensed under CC BY 4.0.