o
    e
                     @   s,   d dl Z G dd deZG dd deZdS )    Nc                   @   s   e Zd ZdS )TwilioExceptionN)__name__
__module____qualname__ r   r   I/var/www/html/venv/lib/python3.10/site-packages/twilio/base/exceptions.pyr      s    r   c                   @   s"   e Zd ZdZd	ddZ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 str method: The HTTP method used to make the request
    :param int|None code: A Twilio-specific error code for the error. This is
         not available for all errors.
    :param dictionary|None details: Additional error details returned for the exception
     NGETc                 C   s(   || _ || _|| _|| _|| _|| _d S )N)uristatusmsgcodemethoddetails)selfr   r   r   r   r   r   r   r   r   __init__   s   
zTwilioRestException.__init__c                 C   s   dd }dd }dd }dd }d	d
 }t tjdrTtj rTdj|d|d|d| j| jf |d|t| jd}| j	rRd
|dj|d||| j	dg}|S d| j| jS )z@ Try to pretty-print the exception, if this is going on screen. c                 S      d|  S )Nz[31m[49m%s[0mr   wordsr   r   r   red       z(TwilioRestException.__str__.<locals>.redc                 S   r   )Nz[37m[49m%s[0mr   r   r   r   r   white#   r   z*TwilioRestException.__str__.<locals>.whitec                 S   r   )Nz[34m[49m%s[0mr   r   r   r   r   blue&   r   z)TwilioRestException.__str__.<locals>.bluec                 S   r   )Nz[36m[49m%s[0mr   r   r   r   r   teal)   r   z)TwilioRestException.__str__.<locals>.tealc                 S   s
   d | S )Nz&https://www.twilio.com/docs/errors/{0})format)r   r   r   r   get_uri,   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:)	red_errorrequest_was	http_linetwilio_returnedmessager	   z
{more_info}

{uri}

z'More information may be available here:)	more_infor   zHTTP {0} error: {1})hasattrsysstderrr   r   r   r   strr   r   joinr   )r   r   r   r   r   r   r   r   r   r   __str__   s0   


zTwilioRestException.__str__)r	   Nr
   N)r   r   r   __doc__r   r)   r   r   r   r   r   	   s    
r   )r%   	Exceptionr   r   r   r   r   r   <module>   s   