PowerShell / PowerShell/PowerShell
ConciseView mangles multiline errors thrown from scripts, but not from binary cmdlets
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 55.5k
- Forks
- 8.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 88
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
echo 'throw "test`ntest"' >script.ps1
.\script.ps1
If a script throws a multi-line error using throw, all newlines are replaced with spaces. This does not happen with binary cmdlets and advanced functions using $PSCmdlet.ThrowTerminatingError(). Structured error messages are much harder to read this way. Example from one of my scripts:
throw ("Pog cannot create symbolic links, which are currently necessary for correct functionality.`n" +`
"To allow creating symbolic links, do any of the following and re-run '$PSCommandPath':`n" +`
" 1) Enable Developer Mode. (Settings -> Update & Security -> For developers -> Developer Mode)`n" +`
" 2) Allow your user account to create symbolic links using Group Policy.`n" +`
" (Windows Settings -> Security Settings -> Local Policies -> User Rights Assignment -> Create symbolic links)`n" +`
" 3) Always run Pog as administrator.")
Expected behavior
Exception: D:\_\pog\setup.ps1:39
Line |
39 | throw ("Pog cannot create symbolic links, which are currently nec …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Pog cannot create symbolic links, which are currently necessary for correct functionality.
| To allow creating symbolic links, do any of the following and re-run 'D:\_\pog\setup.ps1':
| 1) Enable Developer Mode. (Settings -> Update & Security -> For developers -> Developer Mode)
| 2) Allow your user account to create symbolic links using Group Policy.
| (Windows Settings -> Security Settings -> Local Policies -> User Rights Assignment -> Create symbolic links)
| 3) Always run Pog as administrator.
Actual behavior
Exception: D:\_\pog\setup.ps1:39
Line |
39 | throw ("Pog cannot create symbolic links, which are currently nec …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Pog cannot create symbolic links, which are currently necessary for correct functionality. To allow creating symbolic links, do any of the following and re-run 'D:\_\pog\setup.ps1': 1) Enable
| Developer Mode. (Settings -> Update & Security -> For developers -> Developer Mode) 2) Allow your user account to create symbolic links using Group Policy. (Windows Settings -> Security
| Settings -> Local Policies -> User Rights Assignment -> Create symbolic links) 3) Always run Pog as administrator.
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.5.0-preview.2
PSEdition Core
GitCommitId 7.5.0-preview.2
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided script.ps1 example and compare ConciseView output for script throw statements against binary cmdlets and advanced functions using $PSCmdlet.ThrowTerminatingError(). Trace the ConciseView error-formatting path; done means multiline script errors retain their newlines while the existing formatting remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100