PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
483 stars 92 forks source link

Provide more detailed error text when resource is not found #1440

Open ThomasNieto opened 11 months ago

ThomasNieto commented 11 months ago

Prerequisites

Steps to reproduce

I saw the GA notice go out (good job getting to GA) and tried to update to the latest and accidently forgot to prefix the module name so it was not found. This produced a generic error message that the module was unable to be installed but in reality it failed due to it not existing.

Please update the failed install error text to say why it failed (module not found, etc).

Install-PSResource PSResourceGet -PassThru

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its Trusted value by running the Set-PSResourceRepository cmdlet. Are you sure you want to install the
PSResource from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
Install-PSResource: Package(s) 'PSResourceGet' could not be installed from repository 'PSGallery'.

Expected behavior

# Module not found error text instead of generic error message

Actual behavior

# Generic error message

Error details

Exception             :
    Type    : Microsoft.PowerShell.PSResourceGet.UtilClasses.ResourceNotFoundException
    Message : Package(s) 'PSResourceGet' could not be installed from repository 'PSGallery'.
    HResult : -2146233088
TargetObject          : Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
CategoryInfo          : InvalidData: (Microsoft.PowerShel…s.InstallPSResource:InstallPSResource) [Install-PSResource], ResourceNotFoundException
FullyQualifiedErrorId : InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
InvocationInfo        :
    MyCommand        : Install-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 1
    Line             : Install-PSResource PSResourceGet -PassThru
    Statement        : Install-PSResource PSResourceGet -PassThru
    PositionMessage  : At line:1 char:1
                       + Install-PSResource PSResourceGet -PassThru
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Install-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :

Environment data

1.0.0
7.4-preview6

Visuals

No response

SydneyhSmith commented 10 months ago

Thanks @ThomasNieto