Merge pull request #93 from PetriAsi/fix/invoke-snipeitmethod-error-handling-#91

If api request to snipe  fails, don't continue, just throw error
This commit is contained in:
Petri Asikainen 2021-05-17 08:12:10 +03:00 committed by GitHub
commit 26e67d2b29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -72,8 +72,9 @@
$webResponse = Invoke-WebRequest @splatParameters $webResponse = Invoke-WebRequest @splatParameters
} }
catch { catch {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Failed to get an answer from the server" #Write-Verbose "[$($MyInvocation.MyCommand.Name)] Failed to get an answer from the server"
$webResponse = $_.Exception.Response #$webResponse = $_.Exception.Response
throw "[$($MyInvocation.MyCommand.Name)] Failed to get an answer from the server. $($_.Exception.Response)"
} }
Write-Debug "[$($MyInvocation.MyCommand.Name)] Executed WebRequest. Access $webResponse to see details" Write-Debug "[$($MyInvocation.MyCommand.Name)] Executed WebRequest. Access $webResponse to see details"