Caught exceptions still appear in global $Error list
Votes from Connect: 3
Original Date Submitted: 9/16/2014 12:15:09 AM
Description:
Contact Information
Handle: Aaron Jensen
Site Name: PowerShell
Feedback ID: 972566
Frequency: Always Happens
Regression: Yes, this happens in previous released versions
Problem Description:
When you catch exceptions, those exception still appear in the global $Error list. I expect that caught exceptions shouldn't appear there because I'm catching and handling them. We have build pipelines that fail builds if there are any errors in the global $Error variable, and this causes false failures in situations where we are handling the exceptions.
$Error.Clear()
try
{
throw 'Blarg!'
}
catch
{
# Caught and handled, Captain!
}
$Error
Note that $Error contains the caught Blarg
exception.
Product Studio item created by Connect Synchronizer due to creation of feedback ID 972566 (http://connect.microsoft.com/PowerShell/feedback/ViewFeedback.aspx?FeedbackID=972566).
Repro Steps:
$Error.Clear()
try
{
throw 'Blarg!'
}
catch
{
}
$Error
Note that $Error contains the Blarg
exception that I caught.
Expected Results:
I would expect the $Error variable to be empty, since I caught and handled the error.
Internal BugId: 11002
