o
    h                     @   s   d dl Z d dlmZ d dlmZmZ d dlmZ d dlm	Z	 e	rKd dl
mZ d dl
mZ d dl
mZ d d	l
mZ d d
lmZ eee eee gef ZG dd deZdd ZdddZdS )    N)Hub)capture_internal_exceptionsevent_from_exception)Integration)TYPE_CHECKING)Callable)Any)Type)Optional)TracebackTypec                   @   s*   e Zd ZdZdZdddZedd ZdS )	ExcepthookIntegration
excepthookFc                 C   s"   t |tstd|f || _d S )Nz7Invalid value for always_run: %s (must be type boolean))
isinstancebool
ValueError
always_run)selfr    r   e/var/www/html/aiguide_backend/venv/lib/python3.10/site-packages/sentry_sdk/integrations/excepthook.py__init__   s   

zExcepthookIntegration.__init__c                   C   s   t tjt_d S )N)_make_excepthooksysr   r   r   r   r   
setup_once&   s   z ExcepthookIntegration.setup_onceNF)__name__
__module____qualname__
identifierr   r   staticmethodr   r   r   r   r   r      s    

r   c                    s    fdd}|S )Nc                    s   t j}|t}|d ur>t|jr>|j}t  t| ||f|j	dddd\}}|j
||d W d    n1 s9w   Y   | ||S )Nr   F)typehandled)client_options	mechanism)hint)r   currentget_integrationr   _should_sendr   clientr   r   optionscapture_event)type_value	tracebackhubintegrationr'   eventr#   old_excepthookr   r   sentry_sdk_excepthook.   s   

z/_make_excepthook.<locals>.sentry_sdk_excepthookr   )r1   r2   r   r0   r   r   ,   s   r   Fc                 C   s   | rdS t tdrdS dS )NTps1F)hasattrr   )r   r   r   r   r&   D   s
   
r&   r   )r   sentry_sdk.hubr   sentry_sdk.utilsr   r   sentry_sdk.integrationsr   sentry_sdk._typesr   typingr   r   r	   r
   typesr   BaseException
Excepthookr   r   r&   r   r   r   r   <module>   s&    