
    Vh=                     L    d dl mZ  G d de      Zd	dZd	dZ G d de      Zy)
    )	to_nativec                   *     e Zd Z fdZd fd	Z xZS )AnsibleAWSErrorc                     | j                   r0| j                  r$| j                   dt        | j                          S t        |          S )Nz: )	exceptionmessager   super__str__)self	__class__s    n/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/amazon/aws/plugins/module_utils/exceptions.pyr
   zAnsibleAWSError.__str__
   s<    >>dllll^2i&?%@AAw      c                     |s|st         |           n!|st         |   |       nt         |   |       || _        || _        |xs i | _        y N)r	   __init__r   r   kwargs)r   r   r   r   r   s       r   r   zAnsibleAWSError.__init__   sK    yGGY'GW%"
 lr   )NN)__name__
__module____qualname__r
   r   __classcell__)r   s   @r   r   r   	   s    !# #r   r   Nc                 L   ddl m} |ddl}|j                         d   }t	        | t
        t        t        f      s| g} t	        |t              rF|j                  r:t	        |j                  |      r$|j                  j                  d   d   | v rt        S t        dt        fi       S )a  Check if the AnsibleAWSError exception is raised by a botocore exception with specific error code.

    Returns AnsibleAWSError if the error code matches, a dummy exception if it does not have an error code or does not match

    Example:
    try:
        describe_instances(connection, InstanceIds=['potato'])
    except is_ansible_aws_error_code('InvalidInstanceID.Malformed'):
        # handle the error for that code case
    except AnsibleAWSError as e:
        # handle the generic error case for all other codes
    r   ClientErrorN   ErrorCodeNeverEverRaisedException)botocore.exceptionsr   sysexc_info
isinstancelisttuplesetr   r   responsetype	Exception)codeer   r   s       r   is_ansible_aws_error_coder*   !   s     0yLLN1dT5#./v1o&KKq{{K0KK  )&1T9*YL"==r   c                    ddl m} |ddl}|j                         d   }t	        |t
              rF|j                  r:t	        |j                  |      r$| |j                  j                  d   d   v rt
        S t        dt        fi       S )a=  Check if the AnsibleAWSError exception raised by a botocore exception contains a specific error message.

    Returns AnsibleAWSError if the error code matches, a dummy exception if it does not have an error code or does not match

    Example:
    try:
        describe_vpc_classic_link(connection, VpcIds=[vpc_id])
    except is_ansible_aws_error_message('The functionality you requested is not available in this region.'):
        # handle the error for that error message
    except AnsibleAWSError as e:
        # handle the generic error case for all other codes
    r   r   Nr   r   Messager   )
r   r   r   r    r!   r   r   r%   r&   r'   )msgr)   r   r   s       r   is_ansible_aws_error_messager.   @   sr     0yLLN11o&KKq{{K01;;''0;;*YL"==r   c                       e Zd Zy)AnsibleBotocoreErrorN)r   r   r    r   r   r0   r0   ]   s    r   r0   r   )ansible.module_utils._textr   r'   r   r*   r.   r0   r1   r   r   <module>r3      s,    1#i #0>>>:	? 	r   