File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,14 +96,34 @@ public async Task<List<ScriptExecuteCommandResult>> ApplyAsync(string clusterCon
9696 var clusterUrl = changeSet . To . Url ;
9797
9898 var kustoHandler = KustoClusterHandlerFactory . Create ( clusterName , clusterUrl ) ;
99- var result = await kustoHandler . WriteAsync ( changeSet ) ;
100-
101- // Add the results from this cluster to the overall results list
102- allResults . AddRange ( result ) ;
99+ try
100+ {
101+ var result = await kustoHandler . WriteAsync ( changeSet ) ;
102+
103+ // Add the results from this cluster to the overall results list
104+ allResults . AddRange ( result ) ;
105+ }
106+ catch ( Exception ex )
107+ {
108+ Log . LogError ( ex , $ "Failed to apply changes to cluster: { clusterName } ") ;
109+ allResults . Add ( CreateFailedClusterResult ( clusterName , clusterUrl , ex ) ) ;
110+ }
103111 }
104112
105113 Log . LogInformation ( $ "Finished applying. Total scripts executed: { allResults . Count } ") ;
106114 return allResults ;
107115 }
116+
117+ private static ScriptExecuteCommandResult CreateFailedClusterResult ( string clusterName , string clusterUrl , Exception exception )
118+ {
119+ return new ScriptExecuteCommandResult
120+ {
121+ CommandType = $ "cluster-script:{ clusterName } ",
122+ OperationId = Guid . Empty ,
123+ Result = "Failed" ,
124+ Reason = $ "{ exception . GetType ( ) . Name } : { exception . Message } ",
125+ CommandText = $ "Apply cluster '{ clusterName } ' ({ clusterUrl } )"
126+ } ;
127+ }
108128 }
109129}
You can’t perform that action at this time.
0 commit comments