def test_commandRaisesUnhandledException(self):
        """
        Wehn a command raises an unhandled exception, the server sends
        a C{BAD} response and logs the exception.
        """

        class UnhandledException(Exception):
            """
            An unhandled exception.
            """

        self.assertCommandExceptionResponse(
            UnhandledException("unhandled"),
            b"001", b"BAD Server error: unhandled\r\n",
        )

        self.assertTrue(self.flushLoggedErrors(UnhandledException))

        Wehn a command raises an unhandled exception, the server sends
        a C{BAD} response and logs the exception.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_imap.py