Skip to content

Commit ecb4199

Browse files
committed
ci(appveyor): improve install script error handling
1 parent 12784a6 commit ecb4199

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

appveyor-install.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1-
$client = New-Object System.Net.WebClient
1+
$ErrorActionPreference = 'Stop'
22

33
# Install PHP
4+
$client = New-Object System.Net.WebClient
45
$phpUrl = "http://windows.php.net/downloads/releases/php-$env:PHP_VERSION-nts-Win32-VC$env:VC_VERSION-x86.zip"
56
$target = Join-Path $PWD 'php.zip'
67
Write-Output "Downloading $phpUrl"
78
try {
89
$client.DownloadFile($phpUrl, $target)
9-
} catch [System.Net.WebException] {
10+
}
11+
catch [System.Net.WebException] {
1012
if ($_.Exception.Response.StatusCode.Value__ -eq 404) {
1113
# Older releases get moved to archives/
1214
$phpUrl = "http://windows.php.net/downloads/releases/archives/php-$env:PHP_VERSION-nts-Win32-VC$env:VC_VERSION-x86.zip"
1315
Write-Output "Downloading $phpUrl"
1416
$client.DownloadFile($phpUrl, $target)
1517
Write-Warning "PHP $env:PHP_VERSION is outdated and was moved to archives"
16-
} else {
18+
}
19+
else {
1720
throw $_
1821
}
1922
}
2023
7z e php.zip -ophp
24+
if ($LASTEXITCODE -ne 0) {
25+
throw "7zip exited with $LASTEXITCODE"
26+
}
2127
Rename-Item .\php\php.ini-development php.ini
2228
$env:PATH += ';' + (Join-Path $PWD 'php')
2329

0 commit comments

Comments
 (0)