Salome HOME
Better exception messages in python nodes.
authorOvidiu MIRCESCU <ovidiu.mircescu@edf.fr>
Tue, 13 Sep 2022 09:22:46 +0000 (11:22 +0200)
committerOvidiu MIRCESCU <ovidiu.mircescu@edf.fr>
Tue, 13 Sep 2022 09:22:46 +0000 (11:22 +0200)
src/runtime/PythonNode.cxx

index b72a37167e4cd57fce2e3f85ded3004de78535df..9cc71d542e14fbe4fe170b8ac98512caa0369c3d 100644 (file)
@@ -497,6 +497,60 @@ void PythonNode::executeRemote()
       _errorDetails=msg.str();
       throw Exception(msg.str());
     }
+  catch(CORBA::COMM_FAILURE& ex)
+    {
+      std::ostringstream msg;
+      msg << "Exception on remote python invocation." << std::endl ;
+      msg << "Caught system exception COMM_FAILURE -- unable to contact the "
+          << "object." << std::endl;
+      _errorDetails=msg.str();
+      throw Exception(msg.str());
+    }
+  catch(CORBA::SystemException& ex)
+    {
+      std::ostringstream msg;
+      msg << "Exception on remote python invocation." << std::endl ;
+      msg << "Caught a CORBA::SystemException." ;
+      CORBA::Any tmp;
+      tmp <<= ex;
+      CORBA::TypeCode_var tc = tmp.type();
+      const char *p = tc->name();
+      if ( *p != '\0' )
+        msg <<p;
+      else
+        msg  << tc->id();
+      msg << std::endl;
+      _errorDetails=msg.str();
+      throw Exception(msg.str());
+    }
+  catch(CORBA::Exception& ex)
+    {
+      std::ostringstream msg;
+      msg << "Exception on remote python invocation." << std::endl ;
+      msg << "Caught CORBA::Exception. " ;
+      CORBA::Any tmp;
+      tmp <<= ex;
+      CORBA::TypeCode_var tc = tmp.type();
+      const char *p = tc->name();
+      if ( *p != '\0' )
+        msg <<p;
+      else
+        msg  << tc->id();
+      msg << std::endl;
+      _errorDetails=msg.str();
+      throw Exception(msg.str());
+    }
+  catch(omniORB::fatalException& fe)
+    {
+      std::ostringstream msg;
+      msg << "Exception on remote python invocation." << std::endl ;
+      msg << "Caught omniORB::fatalException:" << std::endl;
+      msg << "  file: " << fe.file() << std::endl;
+      msg << "  line: " << fe.line() << std::endl;
+      msg << "  mesg: " << fe.errmsg() << std::endl;
+      _errorDetails=msg.str();
+      throw Exception(msg.str());
+    }
 //   if(!CORBA::is_nil(_pynode))
 //     {
 //       _pynode->UnRegister();
@@ -1158,6 +1212,60 @@ void PyFuncNode::executeRemote()
       _errorDetails=msg;
       throw Exception(msg);
     }
+  catch(CORBA::COMM_FAILURE& ex)
+    {
+      std::ostringstream msg;
+      msg << "Exception on remote python invocation." << std::endl ;
+      msg << "Caught system exception COMM_FAILURE -- unable to contact the "
+          << "object." << std::endl;
+      _errorDetails=msg.str();
+      throw Exception(msg.str());
+    }
+  catch(CORBA::SystemException& ex)
+    {
+      std::ostringstream msg;
+      msg << "Exception on remote python invocation." << std::endl ;
+      msg << "Caught a CORBA::SystemException." ;
+      CORBA::Any tmp;
+      tmp <<= ex;
+      CORBA::TypeCode_var tc = tmp.type();
+      const char *p = tc->name();
+      if ( *p != '\0' )
+        msg <<p;
+      else
+        msg  << tc->id();
+      msg << std::endl;
+      _errorDetails=msg.str();
+      throw Exception(msg.str());
+    }
+  catch(CORBA::Exception& ex)
+    {
+      std::ostringstream msg;
+      msg << "Exception on remote python invocation." << std::endl ;
+      msg << "Caught CORBA::Exception. " ;
+      CORBA::Any tmp;
+      tmp <<= ex;
+      CORBA::TypeCode_var tc = tmp.type();
+      const char *p = tc->name();
+      if ( *p != '\0' )
+        msg <<p;
+      else
+        msg  << tc->id();
+      msg << std::endl;
+      _errorDetails=msg.str();
+      throw Exception(msg.str());
+    }
+  catch(omniORB::fatalException& fe)
+    {
+      std::ostringstream msg;
+      msg << "Exception on remote python invocation." << std::endl ;
+      msg << "Caught omniORB::fatalException:" << std::endl;
+      msg << "  file: " << fe.file() << std::endl;
+      msg << "  line: " << fe.line() << std::endl;
+      msg << "  mesg: " << fe.errmsg() << std::endl;
+      _errorDetails=msg.str();
+      throw Exception(msg.str());
+    }
   DEBTRACE( "-----------------end of remote python invocation-----------------" );
   //===========================================================================
   // Get results, unpickle and put them in output ports