예제 #1
0
    def __init__(self, message, error_message=None):
        #print traceback.format_exc()
        Exception.__init__(self, message)

        if error_message is not None:
            self.error_message = error_message
        else:
            self.error_message = ErrorMessage(message.message,
                                              traceback=traceback.format_exc())
예제 #2
0
def error_creator5():
    """Raise a safe style error and append a full message."""
    try:
        error_creator4()
    except SafeError, e4:
        message = ErrorMessage(
            'Creator 5 problem',
            detail=Message(
                Paragraph('Could not', ImportantText('call'), 'function.'),
                Paragraph('Try reinstalling your computer with windows.')),
            suggestion=Message(ImportantText('Important note')))
        e4.error_message.append(message)
        raise
예제 #3
0
    def test_error_message(self):
        """Tests high level error messages are rendered in plain text/html.
        """
        em0 = ErrorMessage('E0p', 'E0d', traceback='E0t')
        em1 = ErrorMessage('E1p')
        em2 = ErrorMessage('E2p', 'E2d', 'E2s', 'E2t')

        em1.append(em2)
        em1.prepend(em0)
        self.maxDiff = None
        expected_res = (
            u'<h5 class="warning"><i class="icon-remove-sign icon-white"></i> '
            'Problem</h5>\n<p>The following problem(s) were encountered '
            'whilst running the analysis.</p>\n<ul>\n<li>E2p</li>\n<li>'
            'E1p</li>\n<li>E0p</li>\n</ul>\n<h5 class="suggestion"><i '
            'class="icon-comment icon-white"></i> Suggestion</h5>\n<p>You can '
            'try the following to resolve the issue:</p>\n<ul>\n<li>E2s</li>'
            '\n</ul>\n<h5 class="problem"><i class="icon-list icon-white">'
            '</i> Details</h5>\n<p>These additional details were reported '
            'when the problem occurred.</p>\n<ul>\n<li>E0d</li>\n<li>E2d'
            '</li>\n</ul>\n<h5 class="inverse" onclick="toggleTracebacks();">'
            '<i class="icon-info-sign icon-white"></i> Diagnostics (click '
            'for details)</h5>\n<ol class="traceback-detail">\n<li>In '
            'file E0t</li>\n<li>In file E2t</li>\n</ol>\n')

        res = em1.to_html()
        self.assertEqual(expected_res, res)

        expected_res = (
            '*****Problem\n\n    The following problem(s) were encountered '
            'whilst running the analysis.\n\n - E2p\n - E1p\n - E0p\n\n'
            '*****Suggestion\n\n    You can try the following to resolve the '
            'issue:\n\n - E2s\n\n*****Details\n\n    These additional details '
            'were reported when the problem occurred.\n\n - E0d\n - E2d\n\n'
            '*****Diagnostics (click for details)\n\n 1. In file E0t\n 2. '
            'In file E2t\n\n')
        res = em1.to_text()
        self.assertEqual(expected_res, res)
예제 #4
0
    def test_error_message(self):
        """Tests high level error messages are rendered in plain text/html.
        """
        em0 = ErrorMessage("E0p", "E0d", traceback="E0t")
        em1 = ErrorMessage("E1p")
        em2 = ErrorMessage("E2p", "E2d", "E2s", "E2t")

        em1.append(em2)
        em1.prepend(em0)
        self.maxDiff = None
        expected_res = (
            u'<h5 class="warning"><i class="icon-remove-sign icon-white"></i> '
            "Problem</h5>\n<p>The following problem(s) were encountered "
            "whilst running the analysis.</p>\n<ul>\n<li>E2p</li>\n<li>"
            'E1p</li>\n<li>E0p</li>\n</ul>\n<h5 class="suggestion"><i '
            'class="icon-comment icon-white"></i> Suggestion</h5>\n<p>You can '
            "try the following to resolve the issue:</p>\n<ul>\n<li>E2s</li>"
            '\n</ul>\n<h5 class="problem"><i class="icon-list icon-white">'
            "</i> Details</h5>\n<p>These additional details were reported "
            "when the problem occurred.</p>\n<ul>\n<li>E0d</li>\n<li>E2d"
            '</li>\n</ul>\n<h5 class="inverse" onclick="toggleTracebacks();">'
            '<i class="icon-info-sign icon-white"></i> Diagnostics (click '
            'for details)</h5>\n<ol class="traceback-detail">\n<li>In '
            "file E0t</li>\n<li>In file E2t</li>\n</ol>\n"
        )

        res = em1.to_html()
        self.assertEqual(expected_res, res)

        expected_res = (
            "*****Problem\n\n    The following problem(s) were encountered "
            "whilst running the analysis.\n\n - E2p\n - E1p\n - E0p\n\n"
            "*****Suggestion\n\n    You can try the following to resolve the "
            "issue:\n\n - E2s\n\n*****Details\n\n    These additional details "
            "were reported when the problem occurred.\n\n - E0d\n - E2d\n\n"
            "*****Diagnostics (click for details)\n\n 1. In file E0t\n 2. "
            "In file E2t\n\n"
        )
        res = em1.to_text()
        self.assertEqual(expected_res, res)
예제 #5
0
    def test_error_message(self):
        """Tests high level error messages are rendered in plain text/html.
        """
        em0 = ErrorMessage('E0p', 'E0d', traceback='E0t')
        em1 = ErrorMessage('E1p')
        em2 = ErrorMessage('E2p', 'E2d', 'E2s', 'E2t')

        em1.append(em2)
        em1.prepend(em0)
        expected_res = (
            '<h5 class="warning"><i class="icon-remove-sign icon-white"></i> '
            'Problem</h5>\n<p>The following problem(s) were encountered '
            'whilst running the analysis.</p>\n<ul>\n<li>E2p</li>\n<li>'
            'E1p</li>\n<li>E0p</li>\n</ul>\n<h5 class="suggestion"><i '
            'class="icon-comment icon-white"></i> Suggestion</h5>\n<p>You can '
            'try the following to resolve the issue:</p>\n<ul>\n<li>E2s</li>'
            '\n</ul>\n<h5 class="problem"><i class="icon-list icon-white">'
            '</i> Details</h5>\n<p>These additional details were reported '
            'when the problem occurred.</p>\n<ul>\n<li>E0d</li>\n<li>E2d'
            '</li>\n</ul>\n<h5 class="inverse" ><i class="icon-info-sign '
            'icon-white"></i> Diagnostics (click for details)</h5>\n<ol>'
            '\n<li>In file E0t</li>\n<li>In file E2t</li>\n</ol>\n')

        res = em1.to_html()
        self.assertEqual(expected_res, res)

        expected_res = (
            '*****Problem\n\n    The following problem(s) were encountered '
            'whilst running the analysis.\n\n - E2p\n - E1p\n - E0p\n\n'
            '*****Suggestion\n\n    You can try the following to resolve the '
            'issue:\n\n - E2s\n\n*****Details\n\n    These additional details '
            'were reported when the problem occurred.\n\n - E0d\n - E2d\n\n'
            '*****Diagnostics (click for details)\n\n 1. In file E0t\n 2. '
            'In file E2t\n\n')
        res = em1.to_text()
        self.assertEqual(expected_res, res)