a
    !fJ                     @   s8   d dl Z d dlmZ G dd deZG dd deZdS )    N)Optionalc                   @   s   e Zd ZdS )TwilioExceptionN)__name__
__module____qualname__ r   r   W/var/www/html/python-backend/venv/lib/python3.9/site-packages/twilio/base/exceptions.pyr      s   r   c                   @   s@   e Zd ZdZdeeeee eee dddZedd	d
Z	dS )TwilioRestExceptiona  A generic 400 or 500 level exception from the Twilio API

    :param int status: the HTTP status that was returned for the exception
    :param str uri: The URI that caused the exception
    :param str msg: A human-readable message for the error
    :param int|None code: A Twilio-specific error code for the error. This is
         not available for all errors.
    :param method: The HTTP method used to make the request
    :param details: Additional error details returned for the exception
     NGET)statusurimsgcodemethoddetailsc                 C   s(   || _ || _|| _|| _|| _|| _d S )N)r   r   r   r   r   r   )selfr   r   r   r   r   r   r   r   r   __init__   s    	zTwilioRestException.__init__)returnc                 C   s   t t ddd}t t ddd}t t ddd}t t ddd	}tt d
dd}ttjdrtj rdj|d|d|d| j| jf |d|t | j	d}| j
rd|dj|d||| j
dg}|S d| j| j	S dS )z>Try to pretty-print the exception, if this is going on screen.)wordsr   c                 S   s   d|  S )Nz[31m[49m%s[0mr   r   r   r   r   red)   s    z(TwilioRestException.__str__.<locals>.redc                 S   s   d|  S )Nz[37m[49m%s[0mr   r   r   r   r   white,   s    z*TwilioRestException.__str__.<locals>.whitec                 S   s   d|  S )Nz[34m[49m%s[0mr   r   r   r   r   blue/   s    z)TwilioRestException.__str__.<locals>.bluec                 S   s   d|  S )Nz[36m[49m%s[0mr   r   r   r   r   teal2   s    z)TwilioRestException.__str__.<locals>.teal)r   r   c                 S   s
   d | S )Nz&https://www.twilio.com/docs/errors/{0})format)r   r   r   r   get_uri5   s    z,TwilioRestException.__str__.<locals>.get_uriisattyzF
{red_error} {request_was}

{http_line}

{twilio_returned}

{message}
z
HTTP ErrorzYour request was:z%s %sz*Twilio returned the following information:)Z	red_errorZrequest_wasZ	http_lineZtwilio_returnedmessager
   z
{more_info}

{uri}

z'More information may be available here:)Z	more_infor   zHTTP {0} error: {1}N)strinthasattrsysstderrr   r   r   r   r   r   joinr   )r   r   r   r   r   r   r   r   r   r   __str__&   s2    
	zTwilioRestException.__str__)r
   Nr   N)
r   r   r   __doc__r    r   r   objectr   r%   r   r   r   r   r	   
   s       r	   )r"   typingr   	Exceptionr   r	   r   r   r   r   <module>   s   