au
au copied to clipboard
Improve error messages when calling au_GetLatest
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: https://github.com/DennisGaida/chocolatey-packages/commit/3e3334a8e4308630df5ee5aee4a097239f8305c3). I would love if AU did parameter validation before actually doing anything and when doing that, also tell me what parameter is wrong.
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 ?
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[...]