PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.67k stars 478 forks source link

Thrown exceptions are not written to the integrated terminal #2587

Closed cveld closed 4 years ago

cveld commented 4 years ago

Issue Description

I am experiencing a problem with exceptions that are not written to the terminal. E.g. I have a simple test.ps1:

throw "test exception"

When running the script with F5 or CTRL-F5 it has three different behaviours seemingly picked randomly:

  1. It does not print any exception in the terminal. This happens most often.
  2. Happening rarely, it prints:
    test exception
    At D:\Work\github\cveld\tse-drive\PowerShell\Initialize-Stubs.ps1:8 char:1
  3. Happening rarely, it prints: (the one you would expect)
    test exception
    At D:\Work\github\cveld\tse-drive\PowerShell\Initialize-Stubs.ps1:8 char:1
    + throw "test exception"
    + ~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (failure:String) [], RuntimeException

When run from the terminal just by typing .\test.ps1 it prints the exception as mentioned under option 3.

Attached Logs

1585241127-448db9c0-588f-43cc-84e0-929f8d852e6c1585049100726.zip

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.18362
VSCode 1.43.1
PowerShell Extension Version 2020.3.0

PowerShell Information

Name Value
PSVersion 5.1.18362.628
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.18362.628
BuildVersion 10.0.18362.628
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand) |Extension|Author|Version| |---|---|---| |Angular-BeastCode|Mikael|8.1.2| |angular-console|nrwl|11.1.3| |angular-essentials|johnpapa|9.0.1| |angular-extension-pack|doggy8088|8.0.1| |angular-extension-pack|loiane|0.7.1| |angular-follow-selector|sanderledegen|1.2.0| |angular-material|1tontech|0.13.0| |angular-schematics|cyrilletuzi|3.3.1| |Angular2|johnpapa|9.1.2| |Angular2|UVBrain|0.4.1| |angular2-inline|natewallace|0.0.17| |angular2-switcher|infinity1207|0.3.3| |Angular2Tests|MarinhoBrandao|0.7.3| |auto-close-tag|formulahendry|0.5.6| |auto-rename-tag|formulahendry|0.1.1| |autoimport|steoates|1.5.3| |azure-account|ms-vscode|0.8.8| |azure-iot-toolkit|vsciot-vscode|2.16.0| |azurerm-vscode-tools|msazurermtools|0.8.4| |cpptools|ms-vscode|0.26.3| |csharp|ms-dotnettools|1.21.15| |debugger-for-chrome|msjsdiag|4.12.6| |debugger-for-edge|msjsdiag|1.0.14| |docthis|joelday|0.7.1| |EditorConfig|EditorConfig|0.14.4| |fast-code-review|nan-jiang|0.3.0| |githistory|donjayamanne|0.6.3| |gremlins|nhoizey|0.15.1| |java|redhat|0.58.0| |JavaScriptSnippets|xabikos|1.7.2| |json-to-ts|MariusAlchimavicius|1.7.4| |json2ts|GregorBiswanger|0.0.6| |markdown-preview-enhanced|shd101wyy|0.5.2| |material-icon-theme|PKief|4.0.1| |move-ts|stringham|1.12.0| |ng-fortytwo-vscode-extension|NG-42|0.0.9| |ng-template|Angular|0.900.18| |path-intellisense|christian-kohler|1.4.2| |plantuml|jebbs|2.13.6| |powershell|ms-vscode|2020.3.0| |prettier-vscode|esbenp|3.20.0| |quicktype|quicktype|12.0.46| |refactorix|krizzdewizz|0.3.6| |remote-wsl|ms-vscode-remote|0.42.4| |simontest|SimonTest|1.8.6| |svelte-vscode|JamesBirtles|0.9.3| |team|ms-vsts|1.161.0| |tslint|eg2|1.0.44| |typescript-hero|rbbit|3.0.0| |typescript-javascript-grammar|ms-vscode|0.0.53| |vscode-arduino|vsciot-vscode|0.2.29| |vscode-docker|ms-azuretools|1.0.0| |vscode-eslint|dbaeumer|2.1.1| |vscode-iot-device-cube|vsciot-vscode|0.1.4| |vscode-iot-workbench|vsciot-vscode|0.12.0| |vscode-java-debug|vscjava|0.25.1| |vscode-java-dependency|vscjava|0.9.0| |vscode-java-pack|vscjava|0.8.1| |vscode-java-test|vscjava|0.22.2| |vscode-logicapps|ms-azuretools|0.2.33| |vscode-maven|vscjava|0.21.2| |vscode-npm-script|eg2|0.3.11| |vscode-peacock|johnpapa|3.6.0| |vscode-simpler-icons|davidbabel|1.6.5| |vscode-todo-highlight|wayou|1.0.4| |vscode-typescript-tslint-plugin|ms-vscode|1.2.3| |vscodeintellicode|VisualStudioExptTeam|1.2.6| |winteriscoming|johnpapa|1.4.1|
TylerLeonhardt commented 4 years ago

Duplicate of https://github.com/PowerShell/vscode-powershell/issues/2576 and fixed already pending a release.

The fix already in the PowerShell Preview extension.

You can still use whatever version of PowerShell you'd like. This is the Preview build of the vs code extension.

ghost commented 4 years ago

This issue has been marked as duplicate and has not had any activity for 1 day. It has been closed for housekeeping purposes.