Get-GithubRepository doesn't appear to honor ErrorAction inside a a try/catch #428
Labels
bug
This relates to a bug in the existing module.
triage needed
An issue that needs to be reviewed by a member of the team.
I write my code inside try/catch blocks and set ErrorActionPrefernce = "Stop" and clear the error stack. When I know something will fail and I want to handle it outside the try/catch then I will pass -ErrorAction SilentlyContinue and capture the result. In the situation described in the title, I have a pipeline in Azure Devops that I use to create a repo, but I need to test if it exists first, then create it if it doesn't. I do this because New-GithubRepository fails when you attempt to create a repo. Part of the pipeline passes the reposoity object onto the pipeline so tasks further down the flow can work properly.
I know at one point this worked as my code (similar to below) is well over a year old. I can confirm the issue exists in v16 and the current v17.
Issue Details
When passing -ErrorAction SilentlyContinue into cmdlet, it should be honored and not throw an error.
Steps to reproduce the issue
Verbose logs showing the problem
Suggested solution to the issue
I'm unsure how to resolve this issue
Requested Assignment
Operating System
PowerShell Version
Module Version
The text was updated successfully, but these errors were encountered: