def fakeCORBAMethod(): ''' Simulates the testing of a fake CORBA method This function: - creates a new native local exception and throws it - catches it as native exception - converts it to an ACS exception using pyExceptionToCORBA() function - throws it again - catches it as a CORBA exception - converts it back into the helper class WITHOUT adding new error info - rethrows the new local exception - catches it as a CORBA exception - converts it back into the helper class AND adds new error info - throws the exception again which should have two error traces ''' print "--fakeCORBAMethod1-------------------------------------------------" try: try: raise Exception("fake python exception") except Exception, ex: print "Raising the local exception..." raise pyExceptionToCORBA(ex) #make sure we can catch the real CORBA exception except ACSErrTypePythonNative.PythonEx, e: #convert it back into the helper class w/o adding error information helperException = ACSErrTypePythonNativeImpl.PythonExImpl(exception=e, create=0) #print to stdout...only one error trace should be seen helperException.Print()
clientErrorComponent.TestReceiveRemoteException() clientErrorComponent.TestReceiveRemoteCompletion() clientErrorComponent.testExceptionFromCompletion() clientErrorComponent.testTypeException() clientErrorComponent.testCORBASystemException() clientErrorComponent.testCompletionFromCompletion() clientErrorComponent.testOutCompletion() except ACSError, ex: # We should never get here, because the methods in the example # should be all self contained and none of them should throw # any exception. badMethodEx = ACSErrTypeCommonImpl.GenericErrorExImpl(exception=ex) badMethodEx.setErrorDesc( "Examples of error handling have thrown an ACS exception") badMethodEx.log(self.logger) except Exception, ex: # We should never get here, because the methods in the example # should be all self contained and none of them should throw # any exception. badMethodEx = pyExceptionToCORBA(ex) badMethodEx.setData( "Reason", "Examples of error handling have thrown an UNEXPECTED exception") badMethodEx.log(self.logger) finally: clientErrorComponent.releaseComponent() client.disconnect()
#Call the displayMessage() method existing in the interface for ErrorComponent clientErrorComponent.TestOk() clientErrorComponent.TestReceiveRemoteException() clientErrorComponent.TestReceiveRemoteCompletion() clientErrorComponent.testExceptionFromCompletion() clientErrorComponent.testTypeException() clientErrorComponent.testCORBASystemException() clientErrorComponent.testCompletionFromCompletion() clientErrorComponent.testOutCompletion() except ACSError, ex: # We should never get here, because the methods in the example # should be all self contained and none of them should throw # any exception. badMethodEx = ACSErrTypeCommonImpl.GenericErrorExImpl(exception = ex) badMethodEx.setErrorDesc("Examples of error handling have thrown an ACS exception") badMethodEx.log(self.logger) except Exception, ex: # We should never get here, because the methods in the example # should be all self contained and none of them should throw # any exception. badMethodEx = pyExceptionToCORBA(ex) badMethodEx.setData("Reason", "Examples of error handling have thrown an UNEXPECTED exception") badMethodEx.log(self.logger) finally: clientErrorComponent.releaseComponent() client.disconnect()