Skip to content

Commit db2aa58

Browse files
committed
update Custom Feature States
1 parent 335770e commit db2aa58

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

Static/customfeaturestates/deploy.ps1

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ function Test-LastExitCode
4646
{
4747
if ($LastExitCode -ne 0 )
4848
{
49-
Write-Err "Operation failed with exit code $LastExitCode" -ErrorAction 'Stop'
50-
exit $LastExitCode
49+
throw "Operation failed with exit code $LastExitCode"
5150
}
5251
}
5352

54-
5553
function Process-Zip-Operation
5654
{
5755
param ($uri, $authPartUri, $outputPath, $operationName)
@@ -66,8 +64,7 @@ function Process-Zip-Operation
6664

6765
if ($scv -ne 200)
6866
{
69-
Write-Err "Failed to send $operationName request. Status code: $scv Response: $(ConvertTo-Json $response -Depth 10)"
70-
exit 1
67+
throw "Failed to send $operationName request. Status code: $scv Response: $(ConvertTo-Json $response -Depth 10)"
7168
}
7269

7370
Expand-Archive $zipPath -DestinationPath $outputPath -Force
@@ -97,16 +94,14 @@ function Process-LRO
9794
# Check if the response status code is 202 - Accepted
9895
if ($scv -ne 202)
9996
{
100-
Write-Err "Failed to send $operationName request. Status code: $scv Response: $(ConvertTo-Json $response -Depth 10)"
101-
exit 1
97+
throw "Failed to send $operationName request. Status code: $scv Response: $(ConvertTo-Json $response -Depth 10)"
10298
}
10399

104100
# Read the response header named "Location" for UDID; "Operation-Location" for everything else
105101
$location = If ($responseHeader.Location -like '') {$responseHeader["Operation-Location"]} Else {$responseHeader.Location}
106102
if ($location -like '')
107103
{
108-
Write-Err "Failed to determine location from response for $operationName request. Response header: $responseHeader"
109-
exit 1
104+
throw "Failed to determine location from response for $operationName request. Response header: $responseHeader"
110105
}
111106

112107
$location = $location.Trim() + $authPartUri
@@ -124,16 +119,14 @@ function Process-LRO
124119
# Check if the response JSON has a "status" field set to "Failed" for failed responses
125120
if ($status -eq "Failed")
126121
{
127-
Write-Err "Failed to create artifact for $operationName request. Status: $($statusResponse.statusMessage), Code: $scv, Response: $(ConvertTo-Json $statusResponse -Depth 10)"
128-
exit 1
122+
throw "Failed to create artifact for $operationName request. Status: $($statusResponse.statusMessage), Code: $scv, Response: $(ConvertTo-Json $statusResponse -Depth 10)"
129123
}
130124

131125
$resourceLocation = If ($statusResponse.resourceLocation -like '') {$rh["Resource-Location"]} Else {$statusResponse.resourceLocation}
132126

133127
if ($resourceLocation -like '')
134128
{
135-
Write-Err "Failed to determine resource location from response for $operationName request. Response: $(ConvertTo-Json $statusResponse -Depth 10)"
136-
exit 1
129+
throw "Failed to determine resource location from response for $operationName request. Response: $(ConvertTo-Json $statusResponse -Depth 10)"
137130
}
138131

139132
# Report the GUID after the last "/" as an output. That is the ID of the artifact that was created by this long running operation.

0 commit comments

Comments
 (0)