Skip to content

New error view stuff blows up when a non-ErrorRecord is in $error #11459

@jazzdelightsme

Description

@jazzdelightsme

And exceptions fail to display at all.

Steps to reproduce

Don't execute these in one single invocation; each line should be entered separately at the interactive prompt:

if foo
$error
$error.Count
$foo = $error[-1]
$foo
$error.Count

Expected behavior

The first line should yield an error, because "if foo" is not valid syntax. And then when we execute "$error" we should see the contents of the $error variable, which should be that same error. And then $error.Count should yield "1". And then when we assign that error into $foo, and then output $foo, we should see the error again. And $error.Count should stay 1.

Actual behavior

When $error is output, we get

InvalidOperation: An error occurred while enumerating through a collection: Collection was modified; enumeration operation may not execute..

And $error.Count is 4, not 1.

And then when we output $foo, get get... nothing. (well, a blank line)

And then $error.Count is 6.

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0-rc.1
PSEdition                      Core
GitCommitId                    7.0.0-rc.1
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions