

def send_error(self, status_code=500, **kwargs):
    'Sends the given HTTP error code to the browser.\n\n        If `flush()` has already been called, it is not possible to send\n        an error, so this method will simply terminate the response.\n        If output has been written but not yet flushed, it will be discarded\n        and replaced with the error page.\n\n        Override `write_error()` to customize the error page that is returned.\n        Additional keyword arguments are passed through to `write_error`.\n        '
    if self._headers_written:
        gen_log.error('Cannot send error response after headers written')
        if (not self._finished):
            self.finish()
        return
    self.clear()
    reason = None
    if ('exc_info' in kwargs):
        exception = kwargs['exc_info'][1]
        if (isinstance(exception, HTTPError) and exception.reason):
            reason = exception.reason
    self.set_status(status_code, reason=reason)
    try:
        self.write_error(status_code, **kwargs)
    except Exception:
        app_log.error('Uncaught exception in write_error', exc_info=True)
    if (not self._finished):
        self.finish()

dataset/ETHPy150Open RobotWebTools/rosbridge_suite/rosbridge_server/src/tornado/web.py RequestHandler.send_error/original