Skip to content

Commit

Permalink
Added proper error handling to web-request
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSehr committed Nov 16, 2023
1 parent 8c7e316 commit 50696b1
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,12 @@ Describe 'Module tests' -Tag 'Module' {
$implementedSchema = $templateFileContentBicep[$implementedSchemaStartIndex..$implementedSchemaEndIndex]

try {
$expectedSchemaFull = (Invoke-WebRequest -Uri $expectedUdtUrl).Content -split '\n'
$rawReponse = Invoke-WebRequest -Uri $expectedUdtUrl
if (($rawReponse.Headers['Content-Type'] | Out-String) -like "*text/plain*") {
$expectedSchemaFull = $rawReponse.Content -split '\n'
} else {
throw "Failed to fetch schema from [$expectedUdtUrl]. Skipping schema check"
}
} catch {
Write-Warning "Failed to fetch schema from [$expectedUdtUrl]. Skipping schema check"
return
Expand Down

0 comments on commit 50696b1

Please sign in to comment.