Powershell: Formatting for unthrown exception incorrect

Created on 20 Dec 2019  路  3Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

$exception = [ComponentModel.Win32Exception]::new(0x8007007a)

# Send to output normally
$exception

# Throw
throw $exception

Expected behavior

Both the output stream exception and the ErrorRecord wrapped thrown exception to look similar, or at the very least display the Exception.Message text.

# Output stream
The data area passed to a system call is too small.

# Error stream
OperationStopped: The data area passed to a system call is too small.

Actual behavior

# Output stream

Error:

# Error stream
OperationStopped: The data area passed to a system call is too small.

Environment data

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

Including screenshot since the "Actual behavior" section looks potentially confusing on this one:

image

Issue-Bug Resolution-Fixed WG-Engine

All 3 comments

It seems it is ConciseView issue.

/cc @SteveL-MSFT

Looks like I didn't handle the case where an exception isn't wrapped because it wasn't thrown. PR coming soon once I fix a different issue with NormalView.

:tada:This issue was addressed in #11415, which has now been successfully released as v7.0.0-rc.2.:tada:

Handy links:

Was this page helpful?
0 / 5 - 0 ratings