o
    .&ßaÓ  ã                   @   sV   d dl Z e  e¡ZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd	„ d	eƒZ	dS )
é    Nc                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚBaseOperationErrorziA {error_type} error ({error_code}) occurred when calling the {operation_name} operation: {error_message}c                    sF   | j j||||d�}tt| ƒ |¡ || _|| _|| _|| _|| _	d S )N)Ú
error_codeÚerror_messageÚ
error_typeÚoperation_name)
ÚMSG_TEMPLATEÚformatÚsuperr   Ú__init__r   r   r   r   Úhttp_status_code)Úselfr   r   r   r   r   Úmsg©Ú	__class__© ú5/usr/lib/python3/dist-packages/awscli/errorhandler.pyr
      s   þ
zBaseOperationError.__init__)Ú__name__Ú
__module__Ú__qualname__r   r
   Ú__classcell__r   r   r   r   r      s    r   c                   @   ó   e Zd ZdS )ÚClientErrorN©r   r   r   r   r   r   r   r   $   ó    r   c                   @   r   )ÚServerErrorNr   r   r   r   r   r   (   r   r   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚErrorHandlera¾  
    This class is responsible for handling any HTTP errors that occur
    when a service operation is called.  It is registered for the
    ``after-call`` event and will have the opportunity to inspect
    all operation calls.  If the HTTP response contains an error
    ``status_code`` an appropriate error message will be printed and
    the handler will short-circuit all further processing by exiting
    with an appropriate error code.
    c           	      K   sv   t  d|j¡ d }d }|jdkrd}t}n|jdks|jdkr#d}t}|d ur9|  |¡\}}|||||j|jd�‚d S )NzHTTP Response Code: %diô  Úserveri�  i-  Úclient)r   r   r   r   r   )ÚLOGÚdebugÚstatus_coder   r   Ú_get_error_code_and_messageÚname)	r   Úhttp_responseÚparsedÚmodelÚkwargsr   Úerror_classÚcodeÚmessager   r   r   Ú__call__7   s"   
ýþzErrorHandler.__call__c                 C   s8   d}d}d|v r|d }|  d|¡|  d|¡fS ||fS )NÚUnknownÚErrorÚCodeÚMessage)Úget)r   Úresponser(   r)   Úerrorr   r   r   r!   H   s   z(ErrorHandler._get_error_code_and_messageN)r   r   r   Ú__doc__r*   r!   r   r   r   r   r   ,   s    
r   )
ÚloggingÚ	getLoggerr   r   Ú	Exceptionr   r   r   Úobjectr   r   r   r   r   Ú<module>   s   
