3
uQh{                 @   sX   d Z ddlZddlmZmZmZmZmZmZm	Z	m
Z
mZmZ ddlT ddlT dd ZdS )z
This module holds all the base and automatically generated errors that the
Telegram API has. See telethon_generator/errors.json for more.
    N   )
ReadCancelledErrorTypeNotFoundErrorInvalidChecksumErrorInvalidBufferErrorAuthKeyNotFoundSecurityErrorCdnFileTamperedErrorAlreadyInConversationErrorBadMessageError
MultiError)*c             C   s   t j| jj d}|r ||dS xHtD ]@\}}tj|| j}|r&|j rVt|j	dnd}|||dS q&W t
jt| jt}||| j| jdS )z
    Converts a Telegram's RPC Error to a Python error.

    :param rpc_error: the RpcError instance.
    :param request: the request that caused this error.
    :return: the RPCError as a Python exception that represents this error.
    N)requestr   )r   capture)r   messagecode)Zrpc_errors_dictgeterror_messageupperZrpc_errors_rerematchgroupsintgroupZbase_errorsabsZ
error_codeZRPCError)Z	rpc_errorr   clsZ	msg_regexmr    r   </tmp/pip-build-2nz6shyl/telethon/telethon/errors/__init__.pyrpc_message_to_error   s    

r   )__doc__r   commonr   r   r   r   r   r   r	   r
   r   r   ZrpcbaseerrorsZrpcerrorlistr   r   r   r   r   <module>   s
   0