<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_exc_info(self, exc_info=None):
 """Write exception information to the response. Only one of this and ``write_result`` may be called. :param exc_info: 3-tuple of exception information. If omitted, the last exception will be retrieved using ``sys.exc_info()``. """

        exc_info = exc_info or sys.exc_info()
        exc = exc_info[1]
        self.code = StatusCode.error
        for spec in self.result.thrift_spec[1:]:
            if spec and isinstance(exc, spec[3][0]):
                assert not self.finished, "Already sent a response"

                setattr(self.result, spec[2], exc)
                self.finished = True
                return

        # Re-raise the exception (with the same traceback) if it didn't match.
        raise exc_info[0], exc_info[1], exc_info[2]