@@ -349,36 +349,6 @@ function SetDeploymentOutputs(
349349 return $deploymentEnvironmentVariables , $deploymentOutputs
350350}
351351
352- <#
353- Writes Resource Manager errors which often have nested exceptions.
354- https://learn.microsoft.com/dotnet/api/microsoft.azure.commands.resourcemanager.cmdlets.sdkmodels.psresourcemanagererror
355- #>
356- function Write-PSResourceManagerError ($resourceManagerError , [int ]$level , [int ]$maxLevel ) {
357- if (! $resourceManagerError -or ! $resourceManagerError.Message ) {
358- return ;
359- }
360-
361- # Retrieve one or more messages then decode the strings for readability (remove quote escapes, fix link readability, etc.)
362- $parsedMessage = ($resourceManagerError.Message -join " $ ( [System.Environment ]::NewLine) $ ( [System.Environment ]::NewLine) " )
363- $parsedMessage = [System.Net.WebUtility ]::UrlDecode($parsedMessage )
364-
365- $prefix = " " * ($level * 2 ) + " -"
366- Write-Host " $prefix $parsedMessage "
367-
368- # Limit the level of nested exceptions to prevent overwhelming users with details and infinite recursive calls.
369- if ($level -ge $maxLevel ) {
370- if ($resourceManagerError.Details.Count -gt 0 ) {
371- Write-Host " $prefix ... (additional nested errors not shown)"
372- }
373-
374- return ;
375- }
376-
377- foreach ($detail in $resourceManagerError.Details ) {
378- Write-PSResourceManagerError $detail ($level + 1 ) $maxLevel
379- }
380- }
381-
382352function HandleTemplateDeploymentError ($templateValidationResult ) {
383353 Write-Warning " Deployment template validation failed"
384354
@@ -387,10 +357,14 @@ function HandleTemplateDeploymentError($templateValidationResult) {
387357 return
388358 }
389359
360+ # Retrieve one or more messages then decode the strings for readability (remove quote escapes, fix link readability, etc.)
361+ $parsedMessage = ($templateValidationResult.Details.Message -join " $ ( [System.Environment ]::NewLine) $ ( [System.Environment ]::NewLine) " )
362+ $parsedMessage = [System.Net.WebUtility ]::UrlDecode($parsedMessage )
363+
390364 Write-Warning " #####################################################"
391365 Write-Warning " ######### TEMPLATE VALIDATION ERROR DETAILS #########"
392366 Write-Warning " #####################################################"
393- Write-PSResourceManagerError $templateValidationResult 0 5
367+ Write-Host $parsedMessage
394368 Write-Warning " #####################################################"
395369}
396370
0 commit comments