def error(failure): text = "<unknown error>" try: failure.raiseException() except Exception as e: text = error_repr(e) reply = { 'status': 'error', 'execution_count': self.execution_count, 'ename': '', 'evalue': text, 'traceback': [] } return reply, text, 'text/plain'