U
    /e                     @  s   d dl mZ d dlZeeZd dlZd dlmZ d dl	m
Z
 d dlmZ ddlmZ dd	lmZ d
ZG dd deZG dd dee ZdS )    )annotationsN)format_exception)Any)	TypedDict   )ID   )Message)errorc                   @  s   e Zd ZU ded< ded< dS )Errorstrtextz
str | None	tracebackN)__name__
__module____qualname____annotations__ r   r   A/tmp/pip-unpacked-wheel-f5fndrjf/bokeh/protocol/messages/error.pyr   0   s   
r   c                      sB   e Zd ZdZdZdd fddZedddd d	d
dZ  ZS )r
   aL   Define the ``ERROR`` message for reporting error conditions back to a
    Bokeh server.

    The ``content`` fragment of for this message is has the form:

    .. code-block:: python

        {
            'text'      : <error message text>

            # this is optional
            'traceback' : <traceback text>
        }

    ERRORr   )returnc                   sD   t   }|d7 }|| jd 7 }| jd d k	r@|d| jd  7 }|S )Nz --- r   r   
)super__repr__content)selfmsg	__class__r   r   r   G   s    
zerror.__repr__r   r   )
request_idr   metadatar   c           
      K  sL   | j |d}t \}}}|r0dt|||nd}t||d}	| |||	S )af   Create an ``ERROR`` message

        Args:
            request_id (str) :
                The message ID for the message the precipitated the error.

            text (str) :
                The text of any error message or traceback, etc.

        Any additional keyword arguments will be put into the message
        ``metadata`` fragment as-is.

        )r    N)r   r   )Zcreate_headersysexc_infojoinr   r   )
clsr   r   r    headerZex_typeextbr   r   r   r   r   createO   s
    zerror.create)	r   r   r   __doc__Zmsgtyper   classmethodr)   __classcell__r   r   r   r   r
   4   s
   r
   )
__future__r   logging	getLoggerr   logr"   r   r   typingr   Ztyping_extensionsr   Z
core.typesr   messager	   __all__r   r
   r   r   r   r   <module>   s   
