twisted.web.util.formatFailure

Here are the examples of the python api twisted.web.util.formatFailure taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

Example 1

Project: Piped Source File: handlers.py
    def _get_debug_html(self, reason):
        traceback_as_html = util.formatFailure(reason)
        ajax_endpoint = self.request.path + '?__debug__='+str(id(reason))

        here = os.path.abspath(os.path.dirname(__file__))

        template_name = self.settings.get('debug_template', os.path.join(here, 'templates', 'debugger.html'))

        try:
            return self.render_string(template_name, traceback_as_html=traceback_as_html, ajax_endpoint=ajax_endpoint)
        except Exception as e:
            logger.error('Error while rendering debug html template.', exc_info=True)
            raise e

Example 2

Project: SubliminalCollaborator Source File: test_util.py
Function: test_returns_bytes
    def test_returnsBytes(self):
        """
        The return value of L{formatFailure} is a C{str} instance (not a
        C{unicode} instance) with numeric character references for any non-ASCII
        characters meant to appear in the output.
        """
        try:
            raise Exception("Fake bug")
        except:
            result = formatFailure(Failure())

        self.assertIsInstance(result, str)
        self.assertTrue(all(ord(ch) < 128 for ch in result))
        # Indentation happens to rely on NO-BREAK SPACE
        self.assertIn("&#160;", result)