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

Bring back red errors in PowerShell 7.4+ #1

Open
o-o00o-o opened this issue Mar 10, 2023 · 2 comments
Open

Bring back red errors in PowerShell 7.4+ #1

o-o00o-o opened this issue Mar 10, 2023 · 2 comments

Comments

@o-o00o-o
Copy link

FullMode is exactly what is needed for me all the time - full stack trace, great for logs.

However when using it interactively I find that it is harder to spot when errors happen.

Is there any way that the colour can be set? I actually would prefer if the whole error is in normal white but if there was a header/footer row that was in red to show the user that things didn't go according to plan

@o-o00o-o
Copy link
Author

I've had a play with this locally and changed the ErrorView.ps1xml to

<![CDATA[
                    if ($formatter = Get-Command "ConvertTo-$($global:ErrorView -replace "View")ErrorView" -ListImported -ErrorAction Ignore -ParameterName InputObject -ParameterType [System.Management.Automation.ErrorRecord]) {
                      write-host "Error $([string]::new('━', 80))" -ForegroundColor Red
                      &@($formatter)[0] $_
                    } else {
                      ConvertTo-NormalErrorView $_
                    }
                  ]]>

and this produces quite a nice output

image

any chance this could be included in the distribution so everyone can get this?

@Jaykul
Copy link
Member

Jaykul commented Sep 22, 2024

Yeah, apparently, we need to color our own errors now.

That's going to make it really complicated to do this compatibly for old versions of PowerShell.

It used to be the case (you can test this in PS5) that all text we wrote here would be red. Apparently, they've changed this in the latest PowerShell release.

@Jaykul Jaykul changed the title Love FullMode but could there be some text in red? Bring back red errors in PowerShell 7.4+ Sep 22, 2024
Jaykul added a commit that referenced this issue Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants