From 570403596c53c92d24f8749ecf984dd18a2aac97 Mon Sep 17 00:00:00 2001 From: abn Date: Fri, 8 Apr 2016 15:17:32 +0200 Subject: [PATCH] PVServer_ServiceLoader fix: should return a nice Python exception when service can not be loaded (for example when outside SALOME env) --- .../ServiceLoader/PVServer_ServiceLoader.cxx | 11 +++++++++-- .../ServiceLoader/PVServer_ServiceLoader.h | 13 ++++++++++++- .../ServiceLoader/PVServer_ServiceLoader.i | 7 +++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.cxx b/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.cxx index 02790ee8e..cf8ce79e6 100644 --- a/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.cxx +++ b/src/PVServerService/ServiceLoader/PVServer_ServiceLoader.cxx @@ -26,10 +26,17 @@ #include #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) -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); }; -- 2.39.2