o
    #6d                     @  s   d dl mZ d dlZd dlZd dlmZmZmZ d dlm	Z	 d dl
mZ d dlmZmZ ejdk r7dd	lmZ er@eegef ZG d
d dZdddZdS )    )annotationsN)CallableIterableMapping)AbstractContextManager)TracebackType)TYPE_CHECKINGAny)         )BaseExceptionGroupc                   @  s4   e Zd ZdddZdddZdddZdddZdS )_Catcherhandler_map2Mapping[tuple[type[BaseException], ...], _Handler]c                 C  s
   || _ d S N)_handler_map)selfr    r   lC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\exceptiongroup/_catch.py__init__   s   
z_Catcher.__init__returnNonec                 C  s   d S r   r   )r   r   r   r   	__enter__   s   z_Catcher.__enter__etypetype[BaseException] | NoneexcBaseException | NonetbTracebackType | Noneboolc                 C  s`   |d ur.|  |}||u rdS |d u rdS t|tr+z||j ty*   |j|_ w ||dS )NFT)handle_exception
isinstancer   	__cause____context__)r   r   r   r   Z	unhandledr   r   r   __exit__   s   

z_Catcher.__exit__BaseExceptionc           	      C  s<  t |tr|}ntd|g}g }| j D ]c\}}||\}}|rtzz| ty2   ||}Y nw W n. tyL } z||j W Y d }~n,d }~w tyb } z|| W Y d }~nd }~ww t	
|rttd|d|d||sx nq|rt|dkr|d S td|S |rt|jdkr|jd |u r|S |S )N zError trying to handle z with z,. Exception handler must be a sync function.r   r   )r"   r   r   itemssplitextend
exceptionsr&   appendinspectiscoroutine	TypeErrorlen)	r   r   ZexcgroupZnew_exceptionsZ	exc_typeshandlerZmatchedresultnew_excr   r   r   r!   2   sN   


z_Catcher.handle_exceptionN)r   r   )r   r   )r   r   r   r   r   r   r   r    )r   r&   r   r   )__name__
__module____qualname__r   r   r%   r!   r   r   r   r   r      s
    


r   
__handlersFMapping[type[BaseException] | Iterable[type[BaseException]], _Handler]r   AbstractContextManager[None]c                 C  s   t | ts	tdi }|  D ]H\}}t |tr!t|tr!|f}nt |tr+t|}ntdt	|s7td|D ]}t |trEt|tsItdt|t
rRtdq9|||< qt|S )Nzthe argument must be a mappingzCeach key must be either an exception classes or an iterable thereofzhandlers must be callablezHcatching ExceptionGroup with catch() is not allowed. Use except instead.)r"   r   r/   r(   type
issubclassr&   r   tuplecallabler   r   )r7   r   Ztype_or_iterabler1   iterableexc_typer   r   r   catch]   s<   




r@   )r7   r8   r   r9   )
__future__r   r-   syscollections.abcr   r   r   
contextlibr   typesr   typingr   r	   version_info_exceptionsr   r&   Z_Handlerr   r@   r   r   r   r   <module>   s    
L