Skip to content

Nested Errors Are Not Output During Debugging #2548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marshallwp opened this issue Mar 11, 2020 · 1 comment
Closed

Nested Errors Are Not Output During Debugging #2548

marshallwp opened this issue Mar 11, 2020 · 1 comment
Labels
Area-Debugging Issue-Bug A bug to squash. Resolution-Duplicate Will close automatically.

Comments

@marshallwp
Copy link

marshallwp commented Mar 11, 2020

Issue Description

If you debug a script containing nested error handling, any errors thrown by a nested function do not print to the integrated terminal, regardless of ErrorAction preference. Instead, such errors stop execution but do not print to console.

This behavior differs from the behavior of both a standalone powershell terminal, and the behavior of the Integrated Terminal if the script is invoked directly via dot-sourcing.

Simple Example:

function test-error {
[CmdletBinding()]
Param(
    [ValidateNotNullOrEmpty()]
    [string]$str
)
    Write-Host $str
}

try{
    test-error -str $null -ErrorAction Stop
    Write-Host "This should not print"
}
catch {
    throw $_
}

Behavior when debugging in Visual Code:



                  =====> PowerShell Integrated Console <=====


PS C:\Users\user> c:\Users\user\Desktop\test.ps1

PS C:\Users\user> PS C:\Users\user>

Behavior when dot-sourcing in Visual Code:



                  =====> PowerShell Integrated Console <=====


PS C:\Users\user> ."C:\Users\user\Desktop\test.ps1"

Exception: C:\Users\user\Desktop\test.ps1:11:21
Line |
  11 |      test-error -str $null -ErrorAction Stop
     |                      ~~~~~
     | Cannot validate argument on parameter 'str'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

PS C:\Users\user>

Behavior In Stand-Alone Powershell:

PowerShell 7.0.0
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/powershell
Type 'help' to get help.

PS C:\Users\user> ."C:\Users\user\Desktop\test.ps1"
Exception: C:\Users\user\Desktop\test.ps1:11
Line |
  11 |      test-error -str $null -ErrorAction Stop
     |                      ~~~~~
     | Cannot validate argument on parameter 'str'. The argument is null or empty. Provide an argument that
     | is not null or empty, and then try the command again.

PS C:\Users\user>

Attached Logs

6-PowerShell Editor Services.zip

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.18363
VSCode 1.43.0
PowerShell Extension Version 2020.3.0

PowerShell Information

Name Value
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.10032.0 6.0.0 6.1.0 6.2.0 7.0.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
better-comments aaron-bond 2.0.5
mssql ms-mssql 1.9.0
oracledevtools Oracle 19.3.2
powershell ms-vscode 2020.3.0
vscode-firefox-debug firefox-devtools 2.7.0
@ghost ghost added the Needs: Triage Maintainer attention needed! label Mar 11, 2020
@SydneyhSmith
Copy link
Collaborator

Thanks @BinaryWizard904 looks like it is probably the same issue as #2534 we are investigating the cause.

@SydneyhSmith SydneyhSmith added Area-Debugging Issue-Bug A bug to squash. and removed Needs: Triage Maintainer attention needed! labels Mar 11, 2020
@rjmholt rjmholt added the Resolution-Duplicate Will close automatically. label Mar 11, 2020
@rjmholt rjmholt closed this as completed Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Debugging Issue-Bug A bug to squash. Resolution-Duplicate Will close automatically.
Projects
None yet
Development

No branches or pull requests

3 participants