o
    !d                     @   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__ 7usr/lib/python3.10/site-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-  Zclient)r   r   r   r   r   )LOGdebugZstatus_coder   r   _get_error_code_and_messagename)	r   Zhttp_responseparsedmodelkwargsr   Z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ErrorZ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   
