Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native Command Error Handling #277

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions 1-Draft/RFC00XX-Native-Command-Error-Handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ Line |
> equivalent to the existing PowerShell `Set-StrictMode` and does not need to be addressed in this
> RFC.

### $PSNativeCommandErrorAction
### $PSNativeCommandUseErrorActionPreference

The `$PSNativeCommandErrorAction` preference variable will be implemented as a boolean.
The `$PSNativeCommandUseErrorActionPreference` preference variable will be implemented as a boolean.

- When enabled (1), `$ErrorActionPreference` will affect native commands with described behavior.
- When disabled (0), `$ErrorActionPreference` will have no effect to the original behavior.
Expand All @@ -282,8 +282,8 @@ The reported error record object will be the new type: `NativeCommandException`
### Preference variable resolves error handling conflicts

In cases where an existing script already handles non-zero native command errors, the preference
variable `$PSNativeCommandErrorAction` may be set to `$false`. Error handling behavior of the
PowerShell cmdlets is handled separately with `$ErrorActionPreference`.
variable `$PSNativeCommandUseErrorActionPreference` may be set to `$false`. Error handling behavior

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making this name longer seems like the wrong direction to go. Also, if it ends in ActionPreference then I would expect it to be of type [System.Management.Automation.ActionPreference] instead of [bool].

Copy link

@ceztko ceztko Apr 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the variable being boolean and the name ending with Preference sounds weird. The name is so long that Use gets lost while reading. PSNativeCommandErrorActionEnabled, PSEnableNativeCommandErrorAction may better highlight the implicit type of the variable. Still they are long names, though.

of the PowerShell cmdlets is handled separately with `$ErrorActionPreference`.

## Alternative Approaches and Considerations

Expand Down