Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Improve error messages when calling au_GetLatest #204

Open
DennisGaida opened this issue Jan 27, 2020 · 2 comments
Open

Improve error messages when calling au_GetLatest #204

DennisGaida opened this issue Jan 27, 2020 · 2 comments

Comments

@DennisGaida
Copy link

Consider the following global:au_GetLatest:

function global:au_GetLatest {
     $download_url_response32 = Invoke-WebRequest -Uri "nonexisting"
     $download_url_response64 = Invoke-WebRequest -Uri "nonexisting"
     return @{ Version = $version; URL32 = $download_url_response32; URL64 =  $download_url_response64}
}

When executing this within the update-process (update_all.ps1 / test_all.ps1) the exception for the nonexisting URL is not shown, secondly the error reported by validation is simply "URL syntax is invalid: (7,55s)". I don't know what URL is meant.

Whilst the error message is factually correct, I really didn't know why I was getting the error (see my commit correcting the error here: DennisGaida/chocolatey-packages@3e3334a). I would love if AU did parameter validation before actually doing anything and when doing that, also tell me what parameter is wrong.

@majkinetor
Copy link
Owner

This should work like so unless you changed ErrorAction. Throwing inside au_GetLatest shouldn't bring URL syntax is invalid. What happens when you run update.ps1 ?

@DennisGaida
Copy link
Author

DennisGaida commented Jan 27, 2020

Good idea. It behaves differently when using update.ps1 and I can see the exception, that helps (as I know where the exception is coming from, I still don't know what URL is wrong):

λ  .\update.ps1
microsoft-edge - checking updates using AU version 2019.5.22

URL check
URL syntax is invalid:
At C:\Program Files\WindowsPowerShell\Modules\AU\2019.5.22\Public\Update-Package.ps1:110 char:67
+ ... heck_url $url -Options $Latest.Options) { throw "${res}:$url" } else  ...
+                                               ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (URL syntax is invalid::String) [], RuntimeException
    + FullyQualifiedErrorId : URL syntax is invalid:

And update_all.ps1

λ  .\update_all.ps1
Updating 1 automatic packages at 2020-01-27 18:25:20
Push is disabled
NoCheckChocoVersion is disabled
   [1/1] microsoft-edge ERROR:
     URL syntax is invalid: (7,60s)

Running Report[...]

DennisGaida added a commit to DennisGaida/au that referenced this issue Jan 27, 2020
As described in majkinetor#204 we need to know what parameter was responsible for the invalid URL message.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants