Get-FormatData NoSuch.Type.Exists.Or.IsLoaded
An error that indicates that the type does not exist (in the current session).
A quiet no-op. No output, $? reports $True.
PowerShell Core v6.0.0-beta.3 on macOS 10.12.5
PowerShell Core v6.0.0-beta.3 on Ubuntu 16.04.1 LTS
PowerShell Core v6.0.0-beta.3 on Microsoft Windows 10 Pro (64-bit; v10.0.14393)
Windows PowerShell v5.1.15063.413 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
I would like to work on this
@mklement0 @SteveL-MSFT What should the ErrorCategory be?
@faraazahmad:
Thanks for your willingness to take this on.
I'm not the best person to ask, but looking at the enumeration values at https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.errorcategory?view=powershellsdk-1.1.0, perhaps ResourceUnavailable?
@faraazahmad consider it yours! Thanks!
So my code now outputs this:
PS /home/faraaz> Get-FormatData yolo
Get-FormatData : No such type
At line:1 char:1
+ Get-FormatData yolo
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (System.String[]:String[]) [Get-FormatData], Exception
+ FullyQualifiedErrorId : SPECIFIED_TYPE_NOT_FOUND,Microsoft.PowerShell.Commands.GetFormatDataCommand
Is this all right? And should I just check for $? in the test or something more?
:)
HANG ON ... This is a breaking change to the function!!!
Does -ErrorAction SilentlyContinue work, or are you now forcing everyone to wrap this in a try/catch block?
I understand the desire to have this produce an error, but we can't make existing commands throw exceptions in use cases that used to just return nothing.
You're breaking every instance of existing code that looks like this, right?
if(!(Get-FormatData $Type)) {
Update-FormatData -TypeName $Type ...
}