code: def write_exc_info(self, exc_info=None):
          
          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]
docs: 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()``.