]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
PVServer_ServiceLoader fix: should return a nice Python exception when service abn/pvloader_fix
authorabn <adrien.bruneton@cea.fr>
Fri, 8 Apr 2016 13:17:32 +0000 (15:17 +0200)
committerabn <adrien.bruneton@cea.fr>
Fri, 8 Apr 2016 13:17:32 +0000 (15:17 +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 02790ee8ec29ffa51c3940ec63a599f8ab46ba8f..30753520db121346f07ca58e88661fb89c6c9f7f 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 b274d44892cba2479112d8a25e3fc35f34aa76f0..eba9306647885368f17ca101348ff64ad420d8b5 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 f8e4389a2fcf713be8599875c542676b128d71ea..e71f1232068d3d9b75ec4aab68d9028d10fa846e 100644 (file)
 
 %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);
 };