Skip to content

Commit 174ef81

Browse files
authored
Merge pull request #153 from Snow-Shell/fix-152
fix #152
2 parents 420d378 + 3dab8da commit 174ef81

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

ServiceNow/Private/Invoke-ServiceNowRestMethod.ps1

+15-4
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,14 @@ function Invoke-ServiceNowRestMethod {
147147
$oldProgressPreference = $ProgressPreference
148148
$ProgressPreference = 'SilentlyContinue'
149149

150-
$response = Invoke-WebRequest @params
151-
152-
Write-Debug ($response | ConvertTo-Json)
150+
try {
151+
$response = Invoke-WebRequest @params
152+
Write-Debug $response
153+
}
154+
catch {
155+
$ProgressPreference = $oldProgressPreference
156+
throw $_
157+
}
153158

154159
# TODO: this could use some work
155160
# checking for content is good, but at times we'll get content that's not valid
@@ -200,7 +205,13 @@ function Invoke-ServiceNowRestMethod {
200205
}
201206

202207
Write-Verbose ('getting {0}-{1} of {2}' -f ($params.body.sysparm_offset + 1), $end, $totalRecordCount)
203-
$response = Invoke-WebRequest @params -Verbose:$false
208+
try {
209+
$response = Invoke-WebRequest @params -Verbose:$false
210+
}
211+
catch {
212+
$ProgressPreference = $oldProgressPreference
213+
throw $_
214+
}
204215

205216
$content = $response.content | ConvertFrom-Json
206217
if ( $content.PSobject.Properties.Name -contains "result" ) {

0 commit comments

Comments
 (0)