Skip to content

Conversation

@rjmholt
Copy link
Collaborator

@rjmholt rjmholt commented Jul 27, 2021

PR Summary

Fixes #15726.

When an error is thrown due to $ErrorActionPreference = 'Stop', we now mark it at the first opportunity to prevent having the action preference re-interpreted at a later stage (so that a finally block changing the value won't cause the error to be quietly downgraded).

Labelled as a breaking change because the existing behaviour is observable, but I think is a bucket-3 corner case behaviour that users would experience as a bug. Of note is that ordinary errors written with the WriteError() API will exhibit the correct behaviour, and this change just ensures that all other errors behave the same way.

PR Context

PR Checklist

@rjmholt rjmholt added WG-Engine core PowerShell engine, interpreter, and runtime Breaking-Change breaking change that may affect users labels Jul 27, 2021
@ghost ghost assigned anmenaga Jul 27, 2021
@rjmholt rjmholt assigned adityapatwardhan and unassigned anmenaga Jul 27, 2021
@ghost ghost added the Review - Needed The PR is being reviewed label Aug 5, 2021
@ghost
Copy link

ghost commented Aug 5, 2021

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

try
{
$oldEAP = $ErrorActionPreference
$ErrorActionPreference = 'Stop'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test name says nothing about "Stop". Make sense to have tests for all possible ErrorActionPreference values?

@iSazonov iSazonov added CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log labels Aug 10, 2021
@rjmholt
Copy link
Collaborator Author

rjmholt commented Aug 10, 2021

So looking through the behaviour here, it looks like something deeper is still happening in an unexpected way. Compare:

> get-process -banana; write-host 'hello'
Get-Process: A parameter cannot be found that matches parameter name 'banana'.
hello
> try { get-process -banana; write-host 'hello' } catch { }
# No output here

Parameter binding seems to create a non-terminating error that can be caught...

@ghost ghost removed the Review - Needed The PR is being reviewed label Aug 10, 2021
@rjmholt rjmholt marked this pull request as draft August 10, 2021 17:44
@rjmholt
Copy link
Collaborator Author

rjmholt commented Aug 10, 2021

Going to mark this for Working Group review again

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Aug 13, 2021
@ghost ghost added the Stale label Aug 28, 2021
@ghost
Copy link

ghost commented Aug 28, 2021

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment.

@ghost ghost closed this Sep 8, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking-Change breaking change that may affect users CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Stale Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept WG-Engine core PowerShell engine, interpreter, and runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setting error action preference in finally clause affects terminating parameter binding errors

4 participants