code: def raise_db_exception(self):
          
          if not self.messages:
              raise tds_base.Error("Request failed, server didn't send error message")
          msg = None
          while True:
              msg = self.messages[-1]
              if msg['msgno'] == 3621:  # the statement has been terminated
                  self.messages = self.messages[:-1]
              else:
                  break
  
          error_msg = ' '.join(m['message'] for m in self.messages)
          ex = _create_exception_by_message(msg, error_msg)
          raise ex
docs: Raises exception from last server message
  
          This function will skip messages: The statement has been terminated