Skip to content

Lack of CmdletBinding prevents ErrorAction from propagating #53

@tomrowton-alk

Description

@tomrowton-alk

It seems that not having [CmdletBinding()] for the functions is preventing an explicitly passed -ErrorAction from propagating to child calls. For example, if I call Get-FeatureFlagConfigFromFile -jsonConfigPath $f -ErrorAction SilentlyContinue where $f is a path that does not exist, you will get a halting error; however, if I add [CmdletBinding()] to that function, the halting error moves to the child call Confirm-FeatureFlagConfig - and if I add [CmdletBinding()] to that function, then I get back $null like Get-FeatureFlagConfigFromFile code is written.

To reproduce:
Call $c = Get-FeatureFlagConfigFromFile -jsonConfigPath $f where $f is a path that does not exist
then
Call $c2 = Get-FeatureFlagConfigFromFile -jsonConfigPath $f -ErrorAction SilentlyContinue where $f is a path that does not exist

$c2 should be returned without outputting an error to the console, and be $null
I thought this was working in earlier tests, but trying it now, -ErrorAction is not being passed on.

I'm using version 2.1.0 of FeatureFlags in Powershell 5 with the following $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.2673
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.2673
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions