From 738b4c60519448be182b1454092c86d6ccb78d55 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Mon, 17 May 2021 07:55:25 +0300 Subject: [PATCH] If apirequest fails, dont continue, just throw error --- SnipeitPS/Private/Invoke-SnipeitMethod.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 index 8400267..02817e2 100644 --- a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 +++ b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 @@ -72,8 +72,9 @@ $webResponse = Invoke-WebRequest @splatParameters } catch { - Write-Verbose "[$($MyInvocation.MyCommand.Name)] Failed to get an answer from the server" - $webResponse = $_.Exception.Response + #Write-Verbose "[$($MyInvocation.MyCommand.Name)] Failed to get an answer from the server" + #$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"