]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
PVServer_ServiceLoader fix: should return a nice Python exception when service fbt/salome_formation_2016.1
authorabn <adrien.bruneton@cea.fr>
Fri, 8 Apr 2016 13:17:32 +0000 (15:17 +0200)
committerFlorian BRUNET <florian.brunet@opencascade.com>
Thu, 12 May 2016 09:12:52 +0000 (11:12 +0200)
can not be loaded (for example when outside SALOME env)

src/PVServerService/ServiceLoader/PVServer_ServiceLoader.cxx
src/PVServerService/ServiceLoader/PVServer_ServiceLoader.h
src/PVServerService/ServiceLoader/PVServer_ServiceLoader.i

index d97f55b15b371ff03c728f29527cf34b3b31467e..b2896d524a1f5ef698cddcc87c3b16cad4f1b439 100644 (file)
 #include <utilities.h> // MESSAGE() macro
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
+#include <exception>
 
-PVServer_ServiceLoader::PVServer_ServiceLoader():
+PVServer_ServiceLoader::PVServer_ServiceLoader() throw(PVServer_ServiceLoader_Exception):
   myLcc( 0 )
 {
-  myLcc = new SALOME_LifeCycleCORBA();
+  try
+  {
+      myLcc = new SALOME_LifeCycleCORBA();
+  }
+  catch(...)
+  {
+      throw PVServer_ServiceLoader_Exception("Unable to instanciate SALOME_LifeCycleCORBA!");
+  }
 }
 
 PVServer_ServiceLoader::~PVServer_ServiceLoader()
index e3216079845b558ade4082a6098cc9b9798cc236..be1eff82d15c1454815f50a397a1b1fa9e2c75a9 100644 (file)
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(SALOME_Component)
 #include <string>
+#include <exception>
 
 class SALOME_LifeCycleCORBA;
 
+class PVSERVERSERVICELOADER_EXPORT PVServer_ServiceLoader_Exception: public std::exception
+{
+public:
+  PVServer_ServiceLoader_Exception(const std::string & what):_what(what) {}
+  ~PVServer_ServiceLoader_Exception() throw () {}
+  virtual const char* what() const throw() { return _what.c_str(); }
+private:
+  std::string _what;
+};
+
 class PVSERVERSERVICELOADER_EXPORT PVServer_ServiceLoader
 {
 public:
-  PVServer_ServiceLoader();
+  PVServer_ServiceLoader() throw(PVServer_ServiceLoader_Exception);
   virtual ~PVServer_ServiceLoader();
 
   //! Get the IOR of the CORBA service handling the PVServer
index 2e81d58a01822a083471bb71a8d27d56034a61fb..bd69fd6f4f1ceb0c91413d575441f5ca6cb03133 100644 (file)
@@ -6,9 +6,16 @@
 
 %include <std_string.i>
 
+class PVServer_ServiceLoader_Exception
+{
+public:
+  PVServer_ServiceLoader_Exception(const std::string & what);
+};
+
 class PVServer_ServiceLoader
 {
 public:
+  PVServer_ServiceLoader() throw(PVServer_ServiceLoader_Exception);
   //! Get the IOR of the CORBA service handling the PVServer
   std::string findOrLoadService(const std::string& containerName);
 };