PowerShell / PowerShell/PowerShell
ConciseView mangles multiline errors thrown from scripts, but not from binary cmdlets
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C#
- Estrellas
- 55.5k
- Forks
- 8.5k
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 88
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp, powershell
- Área
- cli
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100