o
    �¨Êh¦	  ã                   @   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©Úuc                   @   s   e Zd ZdS )ÚTwilioExceptionN)Ú__name__Ú
__module__Ú__qualname__© r   r   úH/var/www/html/env/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.
    Ú NÚGETc                 C   s"   || _ || _|| _|| _|| _d S )N)ÚuriÚstatusÚmsgÚcodeÚmethod)Úselfr   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   ó   t 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   )r   r   r   Ú__doc__r   r*   r   r   r   r	   r
      s    

r
   )r&   Úsixr   Ú	Exceptionr   r
   r   r   r   r	   Ú<module>   s   