PowerShell / PowerShell/PowerShell
ConciseView mangles multiline errors thrown from scripts, but not from binary cmdlets
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 55.5k
- Fork
- 8.5k
- Merge medio
- 1g 2h
- PR unite (30g)
- 88
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp, powershell
- Ambito
- cli
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100