Closed petervandivier closed 1 year ago
Thanks for the contribution @petervandivier. throw
should be a terminating error, and ErrorActionPreference
is supposed to only allow you to alter the behavior of non-terminating errors. I wouldn't expect you to be able to bypass the throw
with SilentlyContinue
, and yet I was able to repro exactly that.
-ErrorAction
documentation (ephasis mine):
Determines how the cmdlet responds to a non-terminating error from the command. This parameter works only when the command generates a non-terminating error, such as those from the Write-Error cmdlet. ... The ErrorAction parameter has no effect on terminating errors (such as missing data, parameters that aren't valid, or insufficient permissions) that prevent a command from completing successfully.
There are a number of places where this could additionally have issues (like for example in the very next method: Get-GitHubTeamMember
):
I don't want to fix these all one-off. I'd like to address all of these in a single changelist so that we can ensure that we're approaching that issue in a consistent manner across the entire module. And I wouldn't want to do that until I had a better understanding of why -ErrorAction SilentlyContinue
is altering the behavior of a terminating error.
If you have more context as to why PowerShell is allowing -ErrorAction SilentlyContinue
to bypass a terminating throw
command, please add it to the issue that you opened so that we can come up with a holistic approach to fixing this issue across the entire project.
I've updated the original issue with more details on the problem and suggested approaches that can be taken to move forward.
Description
Get-GitHubTeam -TeamName NonExistentTeam -ErrorAction SilentlyContinue
returns empty set instead of teams you didn't nameIssues Fixed
References
N/A
Checklist
-TeamName
param remains the same-ea 0
invocation-ea 0
with non-existent team now returns empty set ✨