@@ -507,7 +507,6 @@ class AzCliCommandInvoker(CommandInvoker):
507507 # pylint: disable=too-many-statements,too-many-locals,too-many-branches
508508 def execute (self , args ):
509509 args_copy = args [:]
510-
511510 from knack .events import (EVENT_INVOKER_PRE_CMD_TBL_CREATE , EVENT_INVOKER_POST_CMD_TBL_CREATE ,
512511 EVENT_INVOKER_CMD_TBL_LOADED , EVENT_INVOKER_PRE_PARSE_ARGS ,
513512 EVENT_INVOKER_POST_PARSE_ARGS ,
@@ -706,12 +705,12 @@ def _what_if(self, args):
706705 index = args .index ('--subscription' )
707706 if index + 1 < len (args ):
708707 subscription_value = args [index + 1 ]
709- subscription_id = subscription_value
708+ subscription_id = subscription_value
710709 else :
711710 from azure .cli .core .commands .client_factory import get_subscription_id
712711 subscription_id = get_subscription_id (self .cli_ctx )
713712 print (f"DEBUG: Using current login subscription ID: { subscription_id } " )
714-
713+
715714 args = ["az" ] + args if args [0 ] != 'az' else args
716715 command = " " .join (args )
717716 what_if_result = show_what_if (self .cli_ctx , command , subscription_id = subscription_id )
@@ -724,14 +723,17 @@ def _what_if(self, args):
724723 # Return the formatted what-if output as the result
725724 # Similar to the normal flow in execute() method
726725 return CommandResultItem (
727- what_if_result ,
726+ what_if_result ,
728727 table_transformer = None ,
729728 is_query_active = self .data .get ('query_active' , False ),
730729 exit_code = 0
731730 )
732- except Exception as ex :
731+ except ( CLIError , ValueError , KeyError ) as ex :
733732 # If what-if service fails, still show an informative message
734- return CommandResultItem (None , exit_code = 1 , error = CLIError (f'What-if preview failed: { str (ex )} \n Note: This was a preview operation. No actual changes were made.' ))
733+ return CommandResultItem (None , exit_code = 1 ,
734+ error = CLIError (f'What-if preview failed: { str (ex )} \n '
735+ f'Note: This was a preview operation. '
736+ f'No actual changes were made.' ))
735737
736738 @staticmethod
737739 def _extract_parameter_names (args ):
0 commit comments