@@ -489,36 +489,16 @@ private TemplateValidationInfo GetTemplateValidationResult(PSDeploymentCmdletPar
489489 try
490490 {
491491 var validationResult = this . ValidateDeployment ( parameters , deployment ) ;
492- switch ( validationResult )
493- {
494- case DeploymentExtended deploymentExtended :
495- return new TemplateValidationInfo ( deploymentExtended . Properties ? . Providers ? . ToList ( ) ?? new List < Provider > ( ) , new List < ErrorDetail > ( ) , deploymentExtended . Properties ? . Diagnostics ? . ToList ( ) ?? new List < DeploymentDiagnosticsDefinition > ( ) ) ;
496- case DeploymentValidationError deploymentValidationError :
497- return new TemplateValidationInfo ( new List < Provider > ( ) , new List < ErrorDetail > ( deploymentValidationError . Error . AsArray ( ) ) , new List < DeploymentDiagnosticsDefinition > ( ) ) ;
498- case JObject obj :
499- // 202 Response is not deserialized in DeploymentsOperations so we should attempt to deserialize the object here before failing
500- // Should attempt to deserialize for success(DeploymentExtended)
501- try
502- {
503- var deploymentDeserialized = SafeJsonConvert . DeserializeObject < DeploymentExtended > ( validationResult . ToString ( ) , ResourceManagementClient . DeserializationSettings ) ;
504- return new TemplateValidationInfo ( deploymentDeserialized ? . Properties ? . Providers ? . ToList ( ) ?? new List < Provider > ( ) , new List < ErrorDetail > ( ) , deploymentDeserialized ? . Properties ? . Diagnostics ? . ToList ( ) ?? new List < DeploymentDiagnosticsDefinition > ( ) ) ;
505- }
506- catch ( Newtonsoft . Json . JsonException )
507- {
508- throw new InvalidOperationException ( $ "Received unexpected type { validationResult . GetType ( ) } ") ;
509- }
510- default :
511- throw new InvalidOperationException ( $ "Received unexpected type { validationResult . GetType ( ) } ") ;
512- }
492+ return new TemplateValidationInfo ( validationResult ) ;
513493 }
514494 catch ( Exception ex )
515495 {
516496 var error = HandleError ( ex ) . FirstOrDefault ( ) ;
517- return new TemplateValidationInfo ( new List < Provider > ( ) , error . AsArray ( ) . ToList ( ) , new List < DeploymentDiagnosticsDefinition > ( ) ) ;
497+ return new TemplateValidationInfo ( new DeploymentValidateResult ( error ) ) ;
518498 }
519499 }
520500
521- private object ValidateDeployment ( PSDeploymentCmdletParameters parameters , Deployment deployment )
501+ private DeploymentValidateResult ValidateDeployment ( PSDeploymentCmdletParameters parameters , Deployment deployment )
522502 {
523503 var scopedDeployment = new ScopedDeployment { Properties = deployment . Properties , Location = deployment . Location } ;
524504
@@ -547,26 +527,26 @@ private object ValidateDeployment(PSDeploymentCmdletParameters parameters, Deplo
547527 }
548528 }
549529
550- private List < ErrorDetail > HandleError ( Exception ex )
530+ private List < ErrorResponse > HandleError ( Exception ex )
551531 {
552532 if ( ex == null )
553533 {
554534 return null ;
555535 }
556536
557- ErrorDetail error = null ;
537+ ErrorResponse error = null ;
558538 var innerException = HandleError ( ex . InnerException ) ;
559539 if ( ex is CloudException )
560540 {
561541 var cloudEx = ex as CloudException ;
562- error = new ErrorDetail ( cloudEx . Body ? . Code , cloudEx . Body ? . Message , cloudEx . Body ? . Target , innerException ) ;
542+ error = new ErrorResponse ( cloudEx . Body ? . Code , cloudEx . Body ? . Message , cloudEx . Body ? . Target , innerException ) ;
563543 }
564544 else
565545 {
566- error = new ErrorDetail ( null , ex . Message , null , innerException ) ;
546+ error = new ErrorResponse ( null , ex . Message , null , innerException ) ;
567547 }
568548
569- return new List < ErrorDetail > { error } ;
549+ return new List < ErrorResponse > { error } ;
570550
571551 }
572552
@@ -1529,7 +1509,7 @@ private DeploymentExtended ExecuteDeploymentInternal(PSDeploymentCmdletParameter
15291509 return ProvisionDeploymentStatus ( parameters , deployment ) ;
15301510 }
15311511
1532- private void DisplayInnerDetailErrorMessage ( ErrorDetail error )
1512+ private void DisplayInnerDetailErrorMessage ( ErrorResponse error )
15331513 {
15341514 WriteError ( string . Format ( ErrorFormat , error . Code , error . Message ) ) ;
15351515 if ( error . Details != null )
0 commit comments