@@ -236,7 +236,10 @@ def deploy(self, app_id, app_name, app_title, title_is_default, tarball, env_var
236236 # assume app exists. if it was deleted then Connect will
237237 # raise an error
238238 app = self .app_get (app_id )
239- self ._server .handle_bad_response (app )
239+ try :
240+ self ._server .handle_bad_response (app )
241+ except RSConnectException as e :
242+ raise RSConnectException (f"{ e } Try setting the --new flag to overwrite the previous deployment." )
240243
241244 app_guid = app ["guid" ]
242245 if env_vars :
@@ -845,11 +848,21 @@ def validate_app_mode(self, *args, **kwargs):
845848 # Don't read app metadata if app-id is specified. Instead, we need
846849 # to get this from the remote.
847850 if isinstance (self .remote_server , RSConnectServer ):
848- app = get_app_info (self .remote_server , app_id )
849- existing_app_mode = AppModes .get_by_ordinal (app .get ("app_mode" , 0 ), True )
851+ try :
852+ app = get_app_info (self .remote_server , app_id )
853+ existing_app_mode = AppModes .get_by_ordinal (app .get ("app_mode" , 0 ), True )
854+ except RSConnectException as e :
855+ raise RSConnectException (
856+ f"{ e } Try setting the --new flag to overwrite the previous deployment."
857+ )
850858 elif isinstance (self .remote_server , PositServer ):
851- app = get_rstudio_app_info (self .remote_server , app_id )
852- existing_app_mode = AppModes .get_by_cloud_name (app .json_data ["mode" ])
859+ try :
860+ app = get_rstudio_app_info (self .remote_server , app_id )
861+ existing_app_mode = AppModes .get_by_cloud_name (app .json_data ["mode" ])
862+ except RSConnectException as e :
863+ raise RSConnectException (
864+ f"{ e } Try setting the --new flag to overwrite the previous deployment."
865+ )
853866 else :
854867 raise RSConnectException ("Unable to infer Connect client." )
855868 if existing_app_mode and existing_app_mode not in (None , AppModes .UNKNOWN , app_mode ):
0 commit comments