Fix legacy ErrorView types to use $host.PrivateData colors (#17705)

This commit is contained in:
Steve Lee
2022-07-18 17:07:47 -07:00
committed by GitHub
parent 53adf5d5d4
commit 1437d85a44
@@ -1296,6 +1296,16 @@ namespace System.Management.Automation.Runspaces
$myinv = $err.InvocationInfo
}
if ($ErrorView -ne 'ConciseView' -and $null -ne $host.PrivateData) {
if ($null -ne $host.PrivateData.ErrorForegroundColor) {
[Console]::ForegroundColor = $host.PrivateData.ErrorForegroundColor
}
if ($null -ne $host.PrivateData.ErrorBackgroundColor) {
[Console]::BackgroundColor = $host.PrivateData.ErrorBackgroundColor
}
}
if ($err.FullyQualifiedErrorId -eq 'NativeCommandErrorMessage' -or $err.FullyQualifiedErrorId -eq 'NativeCommandError') {
$err.Exception.Message
}