My deployment script wraps a copy step in try { Copy-Item $src $dest -Recurse } catch { Write-Host "copy failed"; exit 1 }. When the source path is wrong, the red error text appears but the catch block never runs and the script continues with the next step. The same happens when an external tool such as robocopy or git fails.
Why is the error not caught, and how do I make the script stop on the first failure?




