Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Defining the $ErrorView preference variable in the current scope does not take effect (only in parent scope) #3645

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

Preference variables generally take effect in the scope in which they're defined, which appears not be the case for $ErrorView, which only honors it in an ancestral scope:

Steps to reproduce

& { Set-Variable -Scope 0 VerbosePreference Continue; Write-Verbose 'I will display.' }
& { Set-Variable -Scope 0 ErrorView CategoryView; Get-Item /NoSuchItem }
& { Set-Variable -Scope 1 ErrorView CategoryView; Get-Item /NoSuchItem }

Note: To re-run the test, start a new session, because the last command sets $ErrorView in the global scope.

Expected behavior

I will display.
ObjectNotFound: (/NoSuchItem:String) [Get-Item], ItemNotFoundException
ObjectNotFound: (/NoSuchItem:String) [Get-Item], ItemNotFoundException

Actual behavior

I will display.
Get-Item : Cannot find path '/NoSuchItem' because it does not exist.
At line:1 char:54
+ ... t-Variable -Scope 0 ErrorView CategorizedView; Get-Item /NoSuchItem }
+                                                    ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (/NoSuchItem:String) [Get-Item], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand
ObjectNotFound: (/NoSuchItem:String) [Get-Item], ItemNotFoundException

Setting $ErrorView in the same scope as the failing Get-Item command didn't take effect - contrast this with the $VerbosePreference variable.

Environment data

PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on Darwin Kernel Version 16.5.0: Fri Mar  3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.