@@ -236,7 +236,10 @@ def deploy(self, app_id, app_name, app_title, title_is_default, tarball, env_var
236
236
# assume app exists. if it was deleted then Connect will
237
237
# raise an error
238
238
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." )
240
243
241
244
app_guid = app ["guid" ]
242
245
if env_vars :
@@ -845,11 +848,21 @@ def validate_app_mode(self, *args, **kwargs):
845
848
# Don't read app metadata if app-id is specified. Instead, we need
846
849
# to get this from the remote.
847
850
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
+ )
850
858
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
+ )
853
866
else :
854
867
raise RSConnectException ("Unable to infer Connect client." )
855
868
if existing_app_mode and existing_app_mode not in (None , AppModes .UNKNOWN , app_mode ):
0 commit comments