
    j~                     `    d dl 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	Z
d dlmZ ddZddZy)    N)OptionalTypeAny)TracebackType)	api_errorc                      t         j                  j                  j                  } | "t	        j
                  | j                  d       y y )Ng       @)timeout)
sentry_sdkHubcurrentclientatexitregisterflush)r   s    {/Users/manta/Documents/Projects/TheRoad-I1/backend/.venv/lib/python3.12/site-packages/opik/error_tracking/shutdown_hooks.pyregister_flush_hookr      s4    ^^##**Fc2     c                      t         j                  dt        t           dt        dt        t
           dt        ffd} | t         _        y )Nexception_typeexception_value	tracebackreturnc                    t         j                  j                  j                  }|
 | ||      S d}t	        |t
        j                  j                  t        j                  f      rd}|rt        j                  |        | ||      S )NFT)error)r
   r   r   r   
isinstanceopik
exceptionsOpikExceptionr   ApiErrorcapture_exception)r   r   r   r   is_opik_relatedoriginal_exception_hooks        r   exception_hookz/register_exception_hook.<locals>.exception_hook   s|    
 ''..>*>?IVVdoo;;Y=O=OP
 #O((?&~	RRr   )sys
excepthookr   BaseExceptionr   r   r   )r#   r"   s    @r   register_exception_hookr'      sN    !nnS]+S&S M*S 
	S* $CNr   )r   N)r   r$   r
   typingr   r   r   typesr   opik.exceptionsr   opik.rest_api.corer   r   r'    r   r   <module>r-      s'     
  & &   (3$r   