def get_error_html(self, status_code, **kwargs):
        def get_snippet(fp, target_line, num_lines):
            if fp.endswith('.html'):
                fp = os.path.join(self.get_template_path(), fp)

            half_lines = (num_lines/2)
            try:
                with open(fp) as f:
                    all_lines = [line for line in f]

                    return ''.join(all_lines[target_line-half_lines:target_line+half_lines])
            except Exception, ex:
                logging.error(ex)

                return ''

        if self.application.settings.get('debug', False) is False:
            full_message = kwargs.get('exception', None)
            if not full_message or unicode(full_message) == '':
                full_message = 'Sky is falling!'

            return "<html><title>%(code)d: %(message)s</title><body><h1>%(code)d: %(message)s</h1>%(full_message)s</body></html>" % {
                "code": status_code,
                "message": httplib.responses[status_code],
                "full_message": full_message,
                }
        else:
            exception = kwargs.get('exception', None)

            return self.render_string(exception_template, get_snippet=get_snippet, exception=exception, status_code=status_code, kwargs=kwargs)
dataset/ETHPy150Open lonelycode/Mojo/Mojo/RequestHandlers/PrettyOutputMixin.py/UncaughtExceptionMixin.get_error_html/original