Describe the bug
When parsing the content of the file at FilterFilePath, the function New-AdfPublishOption currently doesn't catch the exception that arises when the file is empty. In such case, calling New-AdfPublishOption -FilterFilePath ".\deployment\rules.txt" will fail at line 49 with an error message You cannot call a method on a null-valued expression. due to $FilterText being empty.
To provide a more contextual error message, I've tried catching this exception downstream like so:
Describe the bug When parsing the content of the file at
FilterFilePath
, the functionNew-AdfPublishOption
currently doesn't catch the exception that arises when the file is empty. In such case, callingNew-AdfPublishOption -FilterFilePath ".\deployment\rules.txt"
will fail at line 49 with an error messageYou cannot call a method on a null-valued expression.
due to$FilterText
being empty.To provide a more contextual error message, I've tried catching this exception downstream like so:
unsuccessfully.
I understand there is no point in passing an empty filter file, but we'd like to catch that edge case in our CI/CD pipeline regardless.
To Reproduce
.\deployment\rules.txt
$opt = New-AdfPublishOption -FilterFilePath ".\deployment\rules.txt"
Expected behaviour A proper typed exception is raised when the provided filter file is empty.
Screenshots n/a
Version of PowerShell module of:
Provide all files to reproduce the issue