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%2Fabn%2Fpvloader_fix;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 02790ee8e..30753520d 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 b274d4489..eba930664 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 f8e4389a2..e71f12320 100644 --- a/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.i +++ b/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.i @@ -25,9 +25,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); };