File: //proc/722141/root/lib/python3.6/site-packages/awscli/__pycache__/errorhandler.cpython-36.pyc
3
�T_� � @ sV d dl Z e je�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd � d e�Z dS )
� Nc s e Zd ZdZ� fdd�Z� ZS )�BaseOperationErrorziA {error_type} error ({error_code}) occurred when calling the {operation_name} operation: {error_message}c sF | j j||||d�}tt| �j|� || _|| _|| _|| _|| _ 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__� �"/usr/lib/python3.6/errorhandler.pyr
s
zBaseOperationError.__init__)�__name__�
__module__�__qualname__r r
�
__classcell__r r )r r r s r c @ s e Zd ZdS )�ClientErrorN)r r r r r r r r $ s r c @ s e Zd ZdS )�ServerErrorN)r r r r r r r r ( s r c @ s e Zd ZdZdd� Zdd� ZdS )�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 jd|j� d }d }|jdkr*d}t}n|jdks>|jdkrFd}t}|d k rr| j|�\}}|||||j|jd��d S )NzHTTP Response Code: %di� Zserveri� i- Zclient)r r r r r )�LOG�debugZstatus_coder r �_get_error_code_and_message�name) r Z
http_responseZparsedZmodel�kwargsr Zerror_class�code�messager r r �__call__7 s
zErrorHandler.__call__c C s8 d}d}d|kr0|d }|j d|�|j d|�fS ||fS )NZUnknown�ErrorZCodeZMessage)�get)r Zresponser 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 )
ZloggingZ getLoggerr r � Exceptionr r r �objectr r r r r �<module>
s