ruạṛ
a �u:j[ � @ s� d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl m Z mZmZ d dl mZmZmZmZmZ dZdZdZd Zd ZdZG dd � d �ZdS )� N)�run_in_threadpool)�Request)�HTMLResponse�PlainTextResponse�Response)�ASGIApp�Message�Receive�Scope�Senda� p { color: #211c1c; } .traceback-container { border: 1px solid #038BB8; } .traceback-title { background-color: #038BB8; color: lemonchiffon; padding: 12px; font-size: 20px; margin-top: 0px; } .frame-line { padding-left: 10px; font-family: monospace; } .frame-filename { font-family: monospace; } .center-line { background-color: #038BB8; color: #f9f6e1; padding: 5px 0px 5px 5px; } .lineno { margin-right: 5px; } .frame-title { font-weight: unset; padding: 10px 10px 10px 10px; background-color: #E4F4FD; margin-right: 10px; color: #191f21; font-size: 17px; border: 1px solid #c7dce8; } .collapse-btn { float: right; padding: 0px 5px 1px 5px; border: solid 1px #96aebb; cursor: pointer; } .collapsed { display: none; } .source-code { font-family: courier; font-size: small; padding-bottom: 10px; } a� <script type="text/javascript"> function collapse(element){ const frameId = element.getAttribute("data-frame-id"); const frame = document.getElementById(frameId); if (frame.classList.contains("collapsed")){ element.innerHTML = "‒"; frame.classList.remove("collapsed"); } else { element.innerHTML = "+"; frame.classList.add("collapsed"); } } </script> a� <html> <head> <style type='text/css'> {styles} </style> <title>Starlette Debugger</title> </head> <body> <h1>500 Server Error</h1> <h2>{error}</h2> <div class="traceback-container"> <p class="traceback-title">Traceback</p> <div>{exc_html}</div> </div> {js} </body> </html> a� <div> <p class="frame-title">File <span class="frame-filename">{frame_filename}</span>, line <i>{frame_lineno}</i>, in <b>{frame_name}</b> <span class="collapse-btn" data-frame-id="{frame_filename}-{frame_lineno}" onclick="collapse(this)">{collapse_button}</span> </p> <div id="{frame_filename}-{frame_lineno}" class="source-code {collapsed}">{code_context}</div> </div> zV <p><span class="frame-line"> <span class="lineno">{lineno}.</span> {line}</span></p> zv <p class="center-line"><span class="frame-line center-line"> <span class="lineno">{lineno}.</span> {line}</span></p> c @ s� e Zd ZdZdeejej edd�dd�Z e eedd�dd �Z eeeeed �dd�Zejeed �dd�Zdeeed�dd�Zeed�dd�Zeeed�dd�Zeeed�dd�ZdS )�ServerErrorMiddlewareaz Handles returning 500 responses when a server error occurs. If 'debug' is set, then traceback responses will be returned, otherwise the designated 'handler' will be called. This middleware class should generally be used to wrap *everything* else up, so that unhandled exceptions anywhere in the stack always result in an appropriate 500 response. NF)�app�handler�debug�returnc C s || _ || _|| _d S �N)r r r )�selfr r r � r �N/opt/bart/bart_venv/lib/python3.9/site-packages/starlette/middleware/errors.py�__init__� s zServerErrorMiddleware.__init__)�scope�receive�sendr c � s |d dkr$| � ||��I d H d S d� td d�� �fdd�}z| � |||�I d H W n� ty� } z�t|�}| jr�| �||�}nL| jd u r�| �||�}n4t� | j�r�| �||�I d H }nt | j||�I d H }� s�|||��I d H |�W Y d }~n d }~0 0 d S )N�type�httpF)�messager c � s"