
                            d Z ddlmZ ddlmZ ddlmZ ddlmZ  G d dej                        Z G d d	ej                        Z	 G d
 de	      Z
 G d de	      Z G d de	      Z G d de	      Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d  d!ej                        Z G d" d#ej                        Z G d$ d%ej                        Z G d& d'ej                        Z G d( d)ej                        Z G d* d+ej                        Zy,)-z0This module holds exceptions raised by commands.    )absolute_import)division)unicode_literals)
exceptionsc                       e Zd Zy)NoAppIdentifiedErrorN)__name__
__module____qualname__     0lib/googlecloudsdk/command_lib/app/exceptions.pyr   r      s    r   r   c                       e Zd ZdZy)DeployErrorz#Base class for app deploy failures.Nr	   r
   r   __doc__r   r   r   r   r      s    +r   r   c                   (     e Zd ZdZ fdZd Z xZS )RepoInfoLoadErrorz2Indicates a failure to load a source context file.c                 F    t         t        |           || _        || _        y N)superr   __init__filenameinner_exception)selfr   r   	__class__s      r   r   zRepoInfoLoadError.__init__$   s     	
T+-DM*Dr   c                 N    dj                  | j                  | j                        S )Nz&Could not read repo info file {0}: {1})formatr   r   r   s    r   __str__zRepoInfoLoadError.__str__)   s$    3::t++- -r   r	   r
   r   r   r   r    __classcell__r   s   @r   r   r   !   s    :+
-r   r   c                       e Zd ZdZd Zy)MultiDeployErrorz9Indicates a failed attempt to deploy multiple image urls.c                      y)NzQNo more than one service may be deployed when using the image-url or appyaml flagr   r   s    r   r    zMultiDeployError.__str__1   s    (r   Nr	   r
   r   r   r    r   r   r   r%   r%   .   s
    A)r   r%   c                       e Zd ZdZd Zy)NoRepoInfoWithImageUrlErrorz?The user tried to specify a repo info file with a docker image.c                      y)Nz?The --repo-info-file option is not compatible with --image_url.r   r   s    r   r    z#NoRepoInfoWithImageUrlError.__str__9   s    Lr   Nr'   r   r   r   r)   r)   6   s    GMr   r)   c                   (     e Zd ZdZ fdZd Z xZS )DefaultBucketAccessErrorz@Indicates a failed attempt to access a project's default bucket.c                 8    t         t        |           || _        y r   )r   r,   r   projectr   r.   r   s     r   r   z!DefaultBucketAccessError.__init__@   s    	
"D24DLr   c                 :    dj                  | j                        S )NztCould not retrieve the default Google Cloud Storage bucket for [{a}]. Please try again or use the [bucket] argument.)ar   r.   r   s    r   r    z DefaultBucketAccessError.__str__D   s    	9:@&4<<&:PQr   r!   r#   s   @r   r,   r,   =   s    HQr   r,   c                       e Zd ZdZd Zd Zy)InvalidVersionIdErrorz Indicates an invalid version ID.c                     || _         y r   version)r   r7   s     r   r   zInvalidVersionIdError.__init__M   	    DLr   c                 :    dj                  | j                        S )NzInvalid version id [{version}].  May only contain lowercase letters, digits, and hyphens. Must begin and end with a letter or digit. Must not exceed 63 characters.r6   )r   r7   r   s    r   r    zInvalidVersionIdError.__str__P   s    	$%+VDLLV%ABr   Nr	   r
   r   r   r   r    r   r   r   r4   r4   J   s    (Br   r4   c                       e Zd ZdZd Zd Zy)MissingApplicationErrorz4If an app does not exist within the current project.c                     || _         y r   )r.   )r   r.   s     r   r   z MissingApplicationError.__init__Z   r8   r   c                 8    dj                  | j                        S )NzThe current Google Cloud project [{0}] does not contain an App Engine application. Use `gcloud app create` to initialize an App Engine application within the project.r2   r   s    r   r    zMissingApplicationError.__str__]   s    	*+16$,,+?@r   Nr:   r   r   r   r<   r<   W   s    <@r   r<   c                   "     e Zd ZdZ fdZ xZS )MissingInstanceErrorz6An instance required for the operation does not exist.c                 J    t         t        |   dj                  |             y )NzInstance [{}] does not exist.)r   r@   r   r   )r   instancer   s     r   r   zMissingInstanceError.__init__g   s!    	
.'..x8:r   r	   r
   r   r   r   r"   r#   s   @r   r@   r@   d   s    >: :r   r@   c                   "     e Zd ZdZ fdZ xZS )MissingVersionErrorz4A version required for the operation does not exist.c                 J    t         t        |   dj                  |             y )NzVersion [{}] does not exist.)r   rE   r   r   )r   r7   r   s     r   r   zMissingVersionError.__init__o   s!    	
t-&--g68r   rC   r#   s   @r   rE   rE   l   s    <8 8r   rE   c                   $     e Zd ZdZd fd	Z xZS )InvalidInstanceTypeErrorz#Instance has the wrong environment.c                 b    dj                  |      }|r|d|z   z  }t        t        |   |       y )Nz+{} instances do not support this operation.z  )r   r   rH   r   )r   environmentmessagemsgr   s       r   r   z!InvalidInstanceTypeError.__init__w   s4    
7
>
>{
KC	TG^c	
"D237r   r   rC   r#   s   @r   rH   rH   t   s    +8 8r   rH   c                   "     e Zd ZdZ fdZ xZS )FileNotFoundErrorz:File or directory that was supposed to exist didn't exist.c                 J    t         t        |   dj                  |             y )Nz[{}] does not exist.)r   rN   r   r   r   pathr   s     r   r   zFileNotFoundError.__init__   s    	
T+,B,I,I$,OPr   rC   r#   s   @r   rN   rN   ~   s    BQ Qr   rN   c                   "     e Zd ZdZ fdZ xZS )DuplicateConfigErrorz"Two config files of the same type.c                 P    t         t        |   dj                  |||             y )Nz[{path1}] and [{path2}] are both trying to define a {t} config file. Only one config file of the same type can be updated at once.)path1path2t)r   rS   r   r   )r   rU   rV   config_typer   s       r   r   zDuplicateConfigError.__init__   s2    	
.	HHNu IO I56r   rC   r#   s   @r   rS   rS      s    *6 6r   rS   c                   "     e Zd ZdZ fdZ xZS )DuplicateServiceErrorz6Two <service>.yaml files defining the same service id.c                 P    t         t        |   dj                  |||             y )Nzv[{path1}] and [{path2}] are both defining the service id [{s}]. All <service>.yaml files must have unique service ids.)rU   rV   s)r   rZ   r   r   )r   rU   rV   
service_idr   s       r   r   zDuplicateServiceError.__init__   s2    	
/	AAGu
 BH B45r   rC   r#   s   @r   rZ   rZ      s    >5 5r   rZ   c                   "     e Zd ZdZ fdZ xZS )UnknownSourceErrorz;The path exists but points to an unknown file or directory.c                 L    t         t        |   dj                  |             y )NzE[{path}] could not be identified as a valid source directory or file.)rQ   )r   r_   r   r   rP   s     r   r   zUnknownSourceError.__init__   s"    	
d,O	T	r   rC   r#   s   @r   r_   r_      s    C r   r_   c                       e Zd ZdZy)NotSupportedPy3Exceptionz%Commands that do not support python3.Nr   r   r   r   rb   rb      s    -r   rb   c                   "     e Zd ZdZ fdZ xZS )UnsupportedRuntimeErrorz5The runtime in app.yaml is not a valid Gen 1 runtime.c                 F    t         |   dj                  ||             y )NzmMigration is not supported for runtime present in [{file_path}]. Currently supported runtimes are: {runtimes})	file_pathruntimesr   r   r   )r   rf   supported_runtimesr   s      r   r   z UnsupportedRuntimeError.__init__   s*    	G	88>*< 9? 9
r   rC   r#   s   @r   rd   rd      s    = r   rd   c                   "     e Zd ZdZ fdZ xZS )InvalidOutputDirectoryErrorz6The output directory given for migration is not empty.c                 D    t         |   dj                  |             y )NzUnable to write to output directory [{dir_path}]. The directory is not empty. Please provide an empty directory to start a new migration.)dir_pathrh   )r   rm   r   s     r   r   z$InvalidOutputDirectoryError.__init__   s"    	G	N		"r   rC   r#   s   @r   rk   rk      s    > r   rk   c                   "     e Zd ZdZ fdZ xZS )MissingGen1ApplicationErrorzFThe project does not contain an AppEngine version with a Gen1 runtime.c                 B    t         |   dj                  |             y )NzSThe provided project {0} does not contain an AppEngine version with a Gen1 runtime.rh   r/   s     r   r   z$MissingGen1ApplicationError.__init__   s    	G	r   rC   r#   s   @r   ro   ro      s    N r   ro   N)r   
__future__r   r   r   googlecloudsdk.corer   Errorr   r   r   r%   r)   r,   r4   r<   r@   rE   rH   rN   rS   rZ   r_   rb   rd   rk   ro   r   r   r   <module>rt      s^    7 &  ' *:++ ,*"" ,
- 
-){ )M+ M
Q{ 
Q
BJ,, 
B
@j.. 
@::++ :8*** 88z// 8Q
(( Q6:++ 65J,, 5)) .z// .	j.. 	*"2"2 *"2"2 r   