Dec 12 2017 12:05 PM
I am wondering about the proper or recommended way to handle Exceptions in the PnP PowerShell cmdlets. I'll use the Get-PnPTerm cmdlet as an example. Currently, if the term does not exist the cmdlet throws a non terminating error: Get-PnPTerm : Specified argument was out of the range of valid values.
Personally, I don't see this as an exception, the term does not exist it's one of the expected conditions. (It also clutters up the output. :))
My question is, should the cmdlet return null or NotFoundException rather than the current ArgumentOutOfRangeException? Or, should we just leave it to the user to suppress the errors with -ErrorAction options?
Dec 12 2017 01:23 PM
Dec 12 2017 02:55 PM
That is what I am asking, in general, if I write new cmdlets, what is the preferred handling approach? (That's why the title reads "when authoring".)