From ce88a557964981b01fea513e8e591f55ea1a8d01 Mon Sep 17 00:00:00 2001 From: Jason Thompson Date: Mon, 12 Sep 2022 09:25:09 -0400 Subject: [PATCH] Fix error handling regression (#71) * Remove unnecessary code * fix error handling regression --- src/internal/Get-MsGraphResults.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/internal/Get-MsGraphResults.ps1 b/src/internal/Get-MsGraphResults.ps1 index 7bf0420..d5fab59 100644 --- a/src/internal/Get-MsGraphResults.ps1 +++ b/src/internal/Get-MsGraphResults.ps1 @@ -133,7 +133,7 @@ function Get-MsGraphResults { else { ## Ignore errors with specific codes else display non-terminating error if ($ResponseDetail['ContentParsed'].error.code -eq 'Request_ResourceNotFound') { - #Write-Error -Exception $_.Exception -Message $ResponseDetail['ContentParsed'].error.message -ErrorId $ResponseDetail['ContentParsed'].error.code -Category $_.CategoryInfo.Category -CategoryActivity $_.CategoryInfo.Activity -CategoryReason $_.CategoryInfo.Reason -CategoryTargetName $_.CategoryInfo.TargetName -CategoryTargetType $_.CategoryInfo.TargetType -TargetObject $_.TargetObject -ErrorVariable cmdError -ErrorAction SilentlyContinue + Write-Error -Exception $_.Exception -Message $ResponseDetail['ContentParsed'].error.message -ErrorId $ResponseDetail['ContentParsed'].error.code -Category $_.CategoryInfo.Category -CategoryActivity $_.CategoryInfo.Activity -CategoryReason $_.CategoryInfo.Reason -CategoryTargetName $_.CategoryInfo.TargetName -CategoryTargetType $_.CategoryInfo.TargetType -TargetObject $_.TargetObject -ErrorVariable cmdError -ErrorAction SilentlyContinue #Write-Warning $ResponseDetail['ContentParsed'].error.message } else { @@ -158,7 +158,7 @@ function Get-MsGraphResults { else { ## Ignore errors with specific codes else display non-terminating error if ($BatchResponse.body.error.code -eq 'Request_ResourceNotFound') { - #Write-Error -Message $BatchResponse.body.error.message -ErrorId $BatchResponse.body.error.code -ErrorVariable cmdError -ErrorAction SilentlyContinue + Write-Error -Message $BatchResponse.body.error.message -ErrorId $BatchResponse.body.error.code -ErrorVariable cmdError -ErrorAction SilentlyContinue #Write-Warning $BatchResponse.body.error.message } else { @@ -444,7 +444,6 @@ function Get-MsGraphResults { $Activity = ('{0} {1}' -f $Request.method.ToUpper(), $uriEndpoint.AbsolutePath) $ProgressState = Start-Progress -Activity $Activity -Total $Total $ProgressState.CurrentIteration = $Result.value.Count - $MaxRetries = 5 try { while (Get-ObjectPropertyValue $Result '@odata.nextLink') { Update-Progress $ProgressState -IncrementBy $Result.value.Count