

def write_error(self, status_code, exc_info=None, error_text=None):
    '\n        Render a custom error page. This is invoked if a handler throws\n        an exception. We also call it manually, in some places.\n        '
    if (status_code == 404):
        self.render('404.html')
        return
    if (status_code == 403):
        if (not error_text):
            error_text = 'Not permitted'
        if exc_info:
            error_text = str(exc_info[1])
        self.render('error.html', status_code=403, exctitle=None, exception=error_text)
        return
    exception = ''
    exctitle = None
    if error_text:
        exception = error_text
    if exc_info:
        exctitle = str(exc_info[1])
        ls = [ln for ln in traceback.format_exception(*exc_info)]
        if exception:
            exception = (exception + '\n')
        exception = (exception + ''.join(ls))
    self.render('error.html', status_code=status_code, exctitle=exctitle, exception=exception)

dataset/ETHPy150Open erkyrath/tworld/lib/tweblib/handlers.py MyHandlerMixin.write_error/original