Skip to content

Commit c662119

Browse files
SufficientDaikonclaude
authored andcommitted
Address mklement0 review: fix error terminology precision
- -ErrorAction Stop promotes to script-terminating, not statement-terminating - $ErrorActionPreference applies to both non-terminating and statement-terminating errors (unlike -ErrorAction parameter) - $ErrorActionPreference = 'Ignore' is now accepted (remove outdated caveat) - Native command non-zero exit emits non-terminating NativeCommandExitException Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e836f56 commit c662119

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

reference/7.6/Microsoft.PowerShell.Core/About/about_CommonParameters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ and execution continues unless you use the `ErrorAction` parameter.
128128
The `-ErrorAction` parameter doesn't prevent statement-terminating errors
129129
(such as missing data, parameters that aren't valid, or insufficient
130130
permissions) from stopping the current statement. However, when set to `Stop`,
131-
it escalates non-terminating errors to statement-terminating errors, making
132-
them catchable by `try/catch`. For more information about error categories, see
131+
it escalates non-terminating errors to script-terminating errors, making them
132+
catchable by `try/catch`. For more information about error categories, see
133133
[about_Error_Handling][15].
134134

135135
- `Break` Enters the debugger when an error occurs or an exception is raised.

reference/7.6/Microsoft.PowerShell.Core/About/about_Error_Handling.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ By default, a non-zero exit code from a native program:
130130
Starting in PowerShell 7.3, the
131131
`$PSNativeCommandUseErrorActionPreference`
132132
experimental preference variable, when set to `$true`, causes a non-zero exit
133-
code to generate an error record that respects `$ErrorActionPreference`.
133+
code to emit a **non-terminating error** whose message states the specific exit
134+
code (a `NativeCommandExitException`). This error then respects
135+
`$ErrorActionPreference`, so setting it to `Stop` promotes the error to a
136+
script-terminating error that can be caught with `try`/`catch`.
134137

135138
## Error state variables
136139

@@ -176,7 +179,7 @@ errors from that command.
176179
| `Continue` | Display the error and continue (default) |
177180
| `SilentlyContinue` | Suppress display, add to `$Error`, continue |
178181
| `Ignore` | Suppress display and do not add to `$Error` |
179-
| `Stop` | **Escalate** to a statement-terminating error |
182+
| `Stop` | **Escalate** to a script-terminating error |
180183
| `Inquire` | Prompt the user for a decision |
181184
| `Break` | Enter the debugger |
182185

@@ -187,12 +190,11 @@ statement-terminating regardless of the caller's preference.
187190
### The $ErrorActionPreference variable
188191

189192
The `$ErrorActionPreference` preference variable applies to all commands in the
190-
current scope and child scopes. It accepts the same values as `-ErrorAction`
191-
except `Ignore` (which is valid only as a parameter value).
193+
current scope and child scopes. It accepts the same values as `-ErrorAction`.
192194

193195
```powershell
194196
$ErrorActionPreference = 'Stop'
195-
# All non-terminating errors in this scope now become statement-terminating
197+
# All non-terminating errors in this scope now become script-terminating
196198
Write-Error 'This now throws' # Generates ActionPreferenceStopException
197199
```
198200

reference/7.6/Microsoft.PowerShell.Core/About/about_Preference_Variables.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,12 @@ The valid values are as follows:
404404
preference. **Suspend** isn't a valid value for the `$ErrorActionPreference`
405405
variable.
406406

407-
`$ErrorActionPreference` and the **ErrorAction** parameter apply to
408-
non-terminating errors. They don't change the behavior of
409-
statement-terminating errors generated by `$PSCmdlet.ThrowTerminatingError()`.
410-
However, when set to **Stop**, they escalate non-terminating errors to
411-
statement-terminating errors. For more information about error categories, see
407+
`$ErrorActionPreference` applies to **both** non-terminating and
408+
statement-terminating errors. Unlike the `-ErrorAction` parameter (which only
409+
affects non-terminating errors), the preference variable can also suppress or
410+
escalate errors generated by `$PSCmdlet.ThrowTerminatingError()`.
411+
When set to **Stop**, it escalates non-terminating errors to
412+
script-terminating errors. For more information about error categories, see
412413
[about_Error_Handling][67]. For more information about the **ErrorAction**
413414
common parameter, see [about_CommonParameters][29].
414415

0 commit comments

Comments
 (0)