def HandleException(self, codeBlock):
		# NOTE - Never returns - raises a ComException
		exc_type, exc_value, exc_traceback = sys.exc_info()
		# If a SERVER exception, re-raise it.  If a client side COM error, it is
		# likely to have originated from the script code itself, and therefore
		# needs to be reported like any other exception.
		if IsCOMServerException(exc_type):
			# Ensure the traceback doesnt cause a cycle.
			exc_traceback = None
			raise
		# It could be an error by another script.
		if issubclass(pythoncom.com_error, exc_type) and exc_value[0]==axscript.SCRIPT_E_REPORTED:
			# Ensure the traceback doesnt cause a cycle.
			exc_traceback = None
			raise Exception(scode=exc_value[0])
		
		exception = error.AXScriptException(self, \
		                       codeBlock, exc_type, exc_value, exc_traceback)

		# Ensure the traceback doesnt cause a cycle.
		exc_traceback = None
		result_exception = error.ProcessAXScriptException(self.scriptSite, self.debugManager, exception)
		if result_exception is not None:
			try:
				self.scriptSite.OnScriptTerminate(None, result_exception)
			except pythoncom.com_error:
				pass # Ignore errors telling engine we stopped.
			# reset ourselves to 'connected' so further events continue to fire.
			self.SetScriptState(axscript.SCRIPTSTATE_CONNECTED)
			raise result_exception
		# I think that in some cases this should just return - but the code
		# that could return None above is disabled, so it never happens.
		RaiseAssert(winerror.E_UNEXPECTED, "Don't have an exception to raise to the caller!")
Beispiel #2
0
    def _HandleException_(self):
        """Called whenever an exception is raised.

       Default behaviour is to print the exception.
    """
        # If not a COM exception, print it for the developer.
        if not IsCOMServerException():
            if self.logger is not None:
                self.logger.exception("pythoncom server error")
            else:
                traceback.print_exc()
        # But still raise it for the framework.
        raise