handlers.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:tcrudge 作者: CodeTeam 项目源码 文件源码
def write_error(self, status_code, **kwargs):
        """
        Method gets traceback, writes it into response, finishes response.

        :param status_code: tornado parameter to format html, we don't use it.
        :type status_code: int
        :param kwargs: in debug mode must contain exc_info.
        :type kwargs: dict
        """
        exc_info = kwargs.get('exc_info')
        if self.settings.get(
                "serve_traceback") and exc_info:  # pragma: no cover
            # in debug mode, try to send a traceback
            self.set_header('Content-Type', 'text/plain')
            for line in traceback.format_exception(*exc_info):
                self.write(line)
        # exc_info[1] - HTTPError instance
        # Finish request with exception body or exception reason
        err_text = getattr(exc_info[1], 'body', self._reason)
        self.write(err_text)
        self.finish()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号