You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Set the property error category when an item is not found, and clean up Activity property #274
If I attempt to retrieve a resource that does not exist, I get an exception. That exception currently shows the category for the error as InvalidOperation, which is incorrect. The operation was valid, but the resource was not found.
This script results in an error from the first command (you'll get an error because there is no user with that random GUID that you just created), and then it shows the category information for the error. The output from the second command will look something like this:
The categorization of this error is being done incorrectly, and that makes it difficult for scripters to properly handle a scenario when a resource is not found. For example, you delete a resource and then want to make sure that it was deleted. The category of InvalidOperation should be reserved for operations that failed due to the operation being invalid. When a resource is not found, you should use [System.Management.Automation.ErrorCategory]::ObjectNotFound as the category instead.
Further, for the Activity property, why does it show an extra "_Get" at the end? I invoked Get-MgUser. I expect the activity would be simply Get-MgUser. What is the significance of the extra verb appended on the end of that string? AB#7414
Activity
peombwa commentedon May 25, 2023
Feature is being tracked externally at Azure/autorest.powershell#888.