@@ -83,19 +83,35 @@ public override void ExecuteCmdlet()
83
83
// -- TBD to move it to common helper and remove hard-coded vaules
84
84
85
85
var response = HydraAdapter . GetProtectedItemOperationStatusByURL ( jobResponse . AzureAsyncOperation ) ;
86
- while ( response . OperationStatus . Status == " InProgress" )
86
+ while ( response . OperationStatus . Status == HydraModel . OperationStatusValues . InProgress )
87
87
{
88
88
response = HydraAdapter . GetProtectedItemOperationStatusByURL ( jobResponse . AzureAsyncOperation ) ;
89
89
System . Threading . Thread . Sleep ( TimeSpan . FromSeconds ( 5 ) ) ;
90
90
}
91
91
92
- if ( response . OperationStatus . Status == "Completed" )
92
+ if ( response . OperationStatus . Status == HydraModel . OperationStatusValues . Succeeded )
93
93
{
94
94
var jobStatusResponse = ( HydraModel . OperationStatusJobExtendedInfo ) response . OperationStatus . Properties ;
95
95
string jobId = jobStatusResponse . JobId ;
96
96
var job = HydraAdapter . GetJob ( jobId ) ;
97
97
WriteObject ( JobConversions . GetPSJob ( job ) ) ;
98
98
}
99
+ else if ( response . OperationStatus . Status == HydraModel . OperationStatusValues . Failed )
100
+ {
101
+ var jobStatusResponse = ( HydraModel . OperationStatusJobExtendedInfo ) response . OperationStatus . Properties ;
102
+ if ( jobStatusResponse != null || ! string . IsNullOrEmpty ( jobStatusResponse . JobId ) )
103
+ {
104
+ string jobId = jobStatusResponse . JobId ;
105
+ var job = HydraAdapter . GetJob ( jobId ) ;
106
+ WriteObject ( JobConversions . GetPSJob ( job ) ) ;
107
+ }
108
+
109
+ var errorMessage ( string . Format ( "Operation failed with error code and error message" ,
110
+ response . OperationStatus . OperationStatusError ,
111
+ response . OperationStatus . OperationStatusError ) ) ;
112
+
113
+ throw new Exception ( errorMessage ) ;
114
+ }
99
115
} ) ;
100
116
}
101
117
}
0 commit comments