Using VS Code Version: 1.44.2 (system setup).
$error.clear()
Write-Host "this is the error message"
Write-Host "the result is $($?)"
$null -eq $LASTEXITCODE
Write-Host "lec is $($LASTEXITCODE)"
$LASTEXITCODE
I have used $error.Clear() before starting debug.
PS C:\src\t> $error.clear()
PS C:\src\t> $error
PS C:\src\t> c:\src\t\Trap.ps1
### debugging started, beak on first statement, $error already has an entry
[DBG]: PS C:\src\t> $error
The term '__Invoke-ReadLineForEditorServices' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
[DBG]: PS C:\src\t>