You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Single cmdlet error handling | Use `-ErrorAction 'Stop'` on the cmdlet | Simpler and more explicit than setting `$ErrorActionPreference`|
615
615
| Calling commands that use ThrowTerminatingError | Set `$ErrorActionPreference = 'Stop'` in caller OR wrap in try-catch | Using `-ErrorAction 'Stop'` alone is NOT sufficient; caller continues after error |
616
616
| Assert-style commands |`$PSCmdlet.ThrowTerminatingError()`| Command purpose is to throw on failure |
617
-
| State-changing commands (catch blocks) |`$PSCmdlet.ThrowTerminatingError()`| Prevents partial state changes; caller must use `-ErrorAction 'Stop'`or set `$ErrorActionPreference`|
617
+
| State-changing commands (catch blocks) |`$PSCmdlet.ThrowTerminatingError()`| Prevents partial state changes; caller must set `$ErrorActionPreference = 'Stop'`OR wrap in try-catch|
618
618
| Private functions (internal use only) |`$PSCmdlet.ThrowTerminatingError()` or `Write-Error`| Behavior is understood by internal callers |
619
619
| Parameter validation in `[ValidateScript()]`|`throw`| Only valid option within validation attributes |
620
620
| Any other scenario in commands | Never use `throw`| Poor error messages; unpredictable behavior |
0 commit comments