Skip to content

Commit

Permalink
Support messages encapsuled in $responseBody.message (#19)
Browse files Browse the repository at this point in the history
enhance error handling
  • Loading branch information
kbakk authored Oct 27, 2020
1 parent 2fed62b commit 77860e4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions IsilonPlatform/IsilonPlatform.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,17 @@ function Send-isiAPI{
$result = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($result)
$responseBody = $reader.ReadToEnd() | ConvertFrom-Json
$responeMessage = $responseBody.errors.message | Out-String
Write-Error $responeMessage
if ($responseBody.PSObject.Properties.name -contains "errors") {
$errorResponse = $_.Exception.Message + " " + $responseBody.errors.message
} elseif ($responseBody.PSObject.Properties.name -contains "message") {
$errorResponse = $_.Exception.Message + " " + $responseBody.message
} else {
$errorResponse = $_.Exception.Message
}
Write-Error $errorResponse
} else {
Write-Error $_.Exception
}

}
$isi_session.timeout = (Get-Date).AddSeconds($isi_session.timeout_inactive)
$ISIObject
Expand Down

0 comments on commit 77860e4

Please sign in to comment.