code: def handle_error(self,
                       request: BaseRequest,
                       status: int=500,
                       exc: Optional[BaseException]=None,
                       message: Optional[str]=None) -> StreamResponse:
          
          self.log_exception("Error handling request", exc_info=exc)
  
          ct = 'text/plain'
          if status == HTTPStatus.INTERNAL_SERVER_ERROR:
              title = '{0.value} {0.phrase}'.format(
                  HTTPStatus.INTERNAL_SERVER_ERROR
              )
              msg = HTTPStatus.INTERNAL_SERVER_ERROR.description
              tb = None
              if self.debug:
                  with suppress(Exception):
                      tb = traceback.format_exc()
  
              if 'text/html' in request.headers.get('Accept', ''):
                  if tb:
                      tb = html_escape(tb)
                      msg = '<h2>Traceback:</h2>\n<pre>{}</pre>'.format(tb)
                  message = (
                      "<html><head>"
                      "<title>{title}</title>"
                      "</head><body>\n<h1>{title}</h1>"
                      "\n{msg}\n</body></html>\n"
                  ).format(title=title, msg=msg)
                  ct = 'text/html'
              else:
                  if tb:
                      msg = tb
                  message = title + '\n\n' + msg
  
          resp = Response(status=status, text=message, content_type=ct)
          resp.force_close()
  
          # some data already got sent, connection is broken
          if request.writer.output_size > 0 or self.transport is None:
              self.force_close()
  
          return resp
docs: Handle errors.
  
          Returns HTTP response with specific status code. Logs additional
          information. It always closes current connection.