From: abn Date: Fri, 8 Apr 2016 13:17:32 +0000 (+0200) Subject: PVServer_ServiceLoader fix: should return a nice Python exception when service X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Ffbt%2Fsalome_formation_2016.1;p=modules%2Fgui.git PVServer_ServiceLoader fix: should return a nice Python exception when service can not be loaded (for example when outside SALOME env) --- diff --git a/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.cxx b/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.cxx index d97f55b15..b2896d524 100644 --- a/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.cxx +++ b/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.cxx @@ -25,11 +25,19 @@ #include // MESSAGE() macro #include #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) +#include -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() diff --git a/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.h b/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.h index e32160798..be1eff82d 100644 --- a/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.h +++ b/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.h @@ -25,13 +25,24 @@ #include #include CORBA_CLIENT_HEADER(SALOME_Component) #include +#include 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 diff --git a/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.i b/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.i index 2e81d58a0..bd69fd6f4 100644 --- a/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.i +++ b/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.i @@ -6,9 +6,16 @@ %include +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); };