Skip to content

When $ErrorView = ConciseView (default), an error output from within a module is stripped of new lines, generating weird looking output. #24108

Open
@mariuselix

Description

Prerequisites

Steps to reproduce

Opening this on behalf of a customer.

  1. Create a simple dummy PowerShell module (e.g: error-test.psm1), containing this:
Function Test-Error {
    $errorMessage = "Line1`r`nLine2`r`n"
    Write-Error -Message "`r`n$errorMessage"
}
    
Function Test-ErrorWrapper {
    Test-Error 
}
  1. Import the module in your current PowerShell session:
    Import-Module <path to>\error-test.psm1
  2. Run the Test-Error function, everything works as expected.
  3. Run the Test-ErrorWrapper (just calling the other function) & the error message is displayed without any line breaks.

Note: if you change $ErrorView to NormalView then the line breaks are displayed as expected, along with the "full error details".

Expected behavior

Test-Error displays the message as intended.

PS C:\> Test-Error
Test-Error:
Line1
Line2

Actual behavior

Test-ErrorWrapper displays the message without the line breaks, everything on a single line.

PS C:\> Test-ErrorWrapper
Test-Error:  Line1 Line2

Error details

No response

Environment data

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.4
PSEdition                      Core
GitCommitId                    7.4.4
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

When $ErrorView is ConciseView (by default in PowerShell 7+), line breaks are missing/removed:
image

When $ErrorView is set to NormalView, the line breaks are there & the message is displayed as intended, along with the "full error details".
image

Metadata

Assignees

No one assigned

    Labels

    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Interactive-Consolethe console experienceWG-ReviewedA Working Group has reviewed this and made a recommendation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions