Commit 63dee9ef authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Implementing correct usage of exceptions. This means that the serrno is...

Implementing correct usage of exceptions. This means that the serrno is correctly set in the C interface now. The correct way to display an error message now is thus to first use sstrerror and then use getErrorMessage for a complement of information
parent 959cb000
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* @(#)$RCSfile: BaseCnvSvc.cpp,v $ $Revision: 1.1.1.1 $ $Release$ $Date: 2004/05/12 12:13:34 $ $Author: sponcec3 $ * @(#)$RCSfile: BaseCnvSvc.cpp,v $ $Revision: 1.2 $ $Release$ $Date: 2004/05/19 16:37:14 $ $Author: sponcec3 $
* *
* *
* *
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
// Include Files // Include Files
#include <map> #include <map>
#include "castor/exception/Exception.hpp"
#include "castor/exception/Internal.hpp"
// Local Includes // Local Includes
#include "ICnvFactory.hpp" #include "ICnvFactory.hpp"
...@@ -68,7 +70,7 @@ bool castor::BaseCnvSvc::removeConverter(const unsigned int id) { ...@@ -68,7 +70,7 @@ bool castor::BaseCnvSvc::removeConverter(const unsigned int id) {
// converter // converter
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
castor::IConverter* castor::BaseCnvSvc::converter(const unsigned int objType) castor::IConverter* castor::BaseCnvSvc::converter(const unsigned int objType)
throw (Exception) { throw (castor::exception::Exception) {
// check if we have one // check if we have one
IConverter* conv = m_converters[objType]; IConverter* conv = m_converters[objType];
if (0 != conv) return conv; if (0 != conv) return conv;
...@@ -76,20 +78,20 @@ castor::IConverter* castor::BaseCnvSvc::converter(const unsigned int objType) ...@@ -76,20 +78,20 @@ castor::IConverter* castor::BaseCnvSvc::converter(const unsigned int objType)
const castor::ICnvFactory* fac = const castor::ICnvFactory* fac =
castor::Converters::instance()->cnvFactory(repType(), objType); castor::Converters::instance()->cnvFactory(repType(), objType);
if (0 == fac) { if (0 == fac) {
Exception e; castor::exception::Internal e;
e.getMessage() << "No factory found for object type " e.getMessage() << "No factory found for object type "
<< objType << " and representation type " << objType << " and representation type "
<< repType() << std::endl; << repType();
throw e; throw e;
} }
m_converters[objType] = fac->instantiate(); m_converters[objType] = fac->instantiate();
if (0!= m_converters[objType]) return m_converters[objType]; if (0!= m_converters[objType]) return m_converters[objType];
// Throw an exception since we did not find any suitable converter // Throw an exception since we did not find any suitable converter
Exception e; castor::exception::Internal e;
e.getMessage() << "No converter for object type " e.getMessage() << "No converter for object type "
<< objType << " and representation type " << objType << " and representation type "
<< repType() << std::endl; << repType();
throw e; throw e;
}; };
...@@ -100,7 +102,7 @@ void castor::BaseCnvSvc::createRep(castor::IAddress* address, ...@@ -100,7 +102,7 @@ void castor::BaseCnvSvc::createRep(castor::IAddress* address,
castor::IObject* object, castor::IObject* object,
ObjectSet& alreadyDone, ObjectSet& alreadyDone,
bool autocommit) bool autocommit)
throw (castor::Exception) { throw (castor::exception::Exception) {
// Look for an adapted converter // Look for an adapted converter
IConverter* conv = converter(object->type()); IConverter* conv = converter(object->type());
// convert // convert
...@@ -115,7 +117,7 @@ void castor::BaseCnvSvc::updateRep(castor::IAddress* address, ...@@ -115,7 +117,7 @@ void castor::BaseCnvSvc::updateRep(castor::IAddress* address,
castor::IObject* object, castor::IObject* object,
ObjectSet& alreadyDone, ObjectSet& alreadyDone,
bool autocommit) bool autocommit)
throw (castor::Exception) { throw (castor::exception::Exception) {
// Look for an adapted converter // Look for an adapted converter
IConverter* conv = converter(object->type()); IConverter* conv = converter(object->type());
// convert // convert
...@@ -130,7 +132,7 @@ void castor::BaseCnvSvc::deleteRep(castor::IAddress* address, ...@@ -130,7 +132,7 @@ void castor::BaseCnvSvc::deleteRep(castor::IAddress* address,
castor::IObject* object, castor::IObject* object,
ObjectSet& alreadyDone, ObjectSet& alreadyDone,
bool autocommit) bool autocommit)
throw (castor::Exception) { throw (castor::exception::Exception) {
// Look for an adapted converter // Look for an adapted converter
IConverter* conv = converter(object->type()); IConverter* conv = converter(object->type());
// convert // convert
...@@ -143,7 +145,7 @@ void castor::BaseCnvSvc::deleteRep(castor::IAddress* address, ...@@ -143,7 +145,7 @@ void castor::BaseCnvSvc::deleteRep(castor::IAddress* address,
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
castor::IObject* castor::BaseCnvSvc::createObj castor::IObject* castor::BaseCnvSvc::createObj
(castor::IAddress* address, castor::ObjectCatalog& newlyCreated) (castor::IAddress* address, castor::ObjectCatalog& newlyCreated)
throw (castor::Exception) { throw (castor::exception::Exception) {
// Look for an adapted converter // Look for an adapted converter
castor::IConverter* conv = converter(address->objType()); castor::IConverter* conv = converter(address->objType());
return conv->createObj(address, newlyCreated); return conv->createObj(address, newlyCreated);
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* @(#)$RCSfile: BaseCnvSvc.hpp,v $ $Revision: 1.1.1.1 $ $Release$ $Date: 2004/05/12 12:13:34 $ $Author: sponcec3 $ * @(#)$RCSfile: BaseCnvSvc.hpp,v $ $Revision: 1.2 $ $Release$ $Date: 2004/05/19 16:37:14 $ $Author: sponcec3 $
* *
* *
* *
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
// Local Includes // Local Includes
#include "ICnvSvc.hpp" #include "ICnvSvc.hpp"
#include "BaseSvc.hpp" #include "BaseSvc.hpp"
#include "Exception.hpp" #include "castor/exception/Exception.hpp"
#include "ObjectSet.hpp" #include "ObjectSet.hpp"
#include "ObjectCatalog.hpp" #include "ObjectCatalog.hpp"
...@@ -81,7 +81,7 @@ namespace castor { ...@@ -81,7 +81,7 @@ namespace castor {
* is found * is found
*/ */
virtual IConverter* converter(const unsigned int objType) virtual IConverter* converter(const unsigned int objType)
throw (Exception); throw (castor::exception::Exception);
/** /**
* gets the representation type, that is the type of * gets the representation type, that is the type of
...@@ -105,7 +105,7 @@ namespace castor { ...@@ -105,7 +105,7 @@ namespace castor {
IObject* object, IObject* object,
ObjectSet& alreadyDone, ObjectSet& alreadyDone,
bool autocommit = false) bool autocommit = false)
throw (Exception); throw (castor::exception::Exception);
/** /**
* Updates foreign representation from a C++ Object. * Updates foreign representation from a C++ Object.
...@@ -123,7 +123,7 @@ namespace castor { ...@@ -123,7 +123,7 @@ namespace castor {
IObject* object, IObject* object,
ObjectSet& alreadyDone, ObjectSet& alreadyDone,
bool autocommit = true) bool autocommit = true)
throw (Exception); throw (castor::exception::Exception);
/** /**
* Deletes foreign representation of a C++ Object. * Deletes foreign representation of a C++ Object.
...@@ -141,7 +141,7 @@ namespace castor { ...@@ -141,7 +141,7 @@ namespace castor {
castor::IObject* object, castor::IObject* object,
castor::ObjectSet& alreadyDone, castor::ObjectSet& alreadyDone,
bool autocommit = true) bool autocommit = true)
throw (castor::Exception); throw (castor::exception::Exception);
/** /**
* Creates C++ object from foreign representation * Creates C++ object from foreign representation
...@@ -158,7 +158,7 @@ namespace castor { ...@@ -158,7 +158,7 @@ namespace castor {
*/ */
virtual IObject* createObj (IAddress* address, virtual IObject* createObj (IAddress* address,
ObjectCatalog& newlyCreated) ObjectCatalog& newlyCreated)
throw (castor::Exception); throw (castor::exception::Exception);
private: private:
/** /**
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* @(#)$RCSfile: BaseObject.cpp,v $ $Revision: 1.1.1.1 $ $Release$ $Date: 2004/05/12 12:13:34 $ $Author: sponcec3 $ * @(#)$RCSfile: BaseObject.cpp,v $ $Revision: 1.2 $ $Release$ $Date: 2004/05/19 16:37:14 $ $Author: sponcec3 $
* *
* *
* *
...@@ -29,13 +29,15 @@ ...@@ -29,13 +29,15 @@
#include "castor/Services.hpp" #include "castor/Services.hpp"
#include "castor/MsgSvc.hpp" #include "castor/MsgSvc.hpp"
#include "castor/BaseObject.hpp" #include "castor/BaseObject.hpp"
#include "castor/Exception.hpp" #include "castor/exception/Exception.hpp"
#include "castor/exception/Internal.hpp"
#include "Cglobals.h" #include "Cglobals.h"
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// msgSvc // msgSvc
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
castor::MsgSvc* castor::BaseObject::msgSvc() throw (castor::Exception) { castor::MsgSvc* castor::BaseObject::msgSvc()
throw (castor::exception::Exception) {
IService* svc = svcs()->service("MsgSvc", IService* svc = svcs()->service("MsgSvc",
castor::MsgSvc::ID()); castor::MsgSvc::ID());
if (0 == svc) return 0; if (0 == svc) return 0;
...@@ -50,7 +52,8 @@ castor::MsgSvc* castor::BaseObject::msgSvc() throw (castor::Exception) { ...@@ -50,7 +52,8 @@ castor::MsgSvc* castor::BaseObject::msgSvc() throw (castor::Exception) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// svcs // svcs
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
castor::Services* castor::BaseObject::svcs() throw (castor::Exception) { castor::Services* castor::BaseObject::svcs()
throw (castor::exception::Exception) {
void **tls; void **tls;
getTLS((void **)&tls); getTLS((void **)&tls);
if (0 == *tls) { if (0 == *tls) {
...@@ -62,11 +65,12 @@ castor::Services* castor::BaseObject::svcs() throw (castor::Exception) { ...@@ -62,11 +65,12 @@ castor::Services* castor::BaseObject::svcs() throw (castor::Exception) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// getTLS // getTLS
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void castor::BaseObject::getTLS(void **thip) throw (castor::Exception) { void castor::BaseObject::getTLS(void **thip)
throw (castor::exception::Exception) {
static int Cns_api_key = -1; static int Cns_api_key = -1;
int rc = Cglobals_get (&Cns_api_key, (void **) thip, sizeof(void *)); int rc = Cglobals_get (&Cns_api_key, (void **) thip, sizeof(void *));
if (*thip == NULL) { if (*thip == NULL) {
Exception ex; castor::exception::Internal ex;
ex.getMessage() << "Could not get thread local storage"; ex.getMessage() << "Could not get thread local storage";
throw ex; throw ex;
} }
...@@ -78,6 +82,7 @@ void castor::BaseObject::getTLS(void **thip) throw (castor::Exception) { ...@@ -78,6 +82,7 @@ void castor::BaseObject::getTLS(void **thip) throw (castor::Exception) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// clog // clog
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
castor::logstream& castor::BaseObject::clog() throw(castor::Exception) { castor::logstream& castor::BaseObject::clog()
throw(castor::exception::Exception) {
return msgSvc()->stream(); return msgSvc()->stream();
} }
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* @(#)$RCSfile: BaseObject.hpp,v $ $Revision: 1.1.1.1 $ $Release$ $Date: 2004/05/12 12:13:34 $ $Author: sponcec3 $ * @(#)$RCSfile: BaseObject.hpp,v $ $Revision: 1.2 $ $Release$ $Date: 2004/05/19 16:37:14 $ $Author: sponcec3 $
* *
* Basic object support, including pointer to Services and log support * Basic object support, including pointer to Services and log support
* *
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
// Include Files // Include Files
#include "castor/logstream.h" #include "castor/logstream.h"
#include "Exception.hpp" #include "castor/exception/Exception.hpp"
namespace castor { namespace castor {
...@@ -47,7 +47,7 @@ namespace castor { ...@@ -47,7 +47,7 @@ namespace castor {
/** /**
* Access to the underlying Services object * Access to the underlying Services object
*/ */
Services* svcs() throw(Exception); Services* svcs() throw(castor::exception::Exception);
/** /**
* gets the message service. * gets the message service.
...@@ -55,19 +55,19 @@ namespace castor { ...@@ -55,19 +55,19 @@ namespace castor {
* @return a pointer to the message service or 0 if none * @return a pointer to the message service or 0 if none
* is available. * is available.
*/ */
MsgSvc* msgSvc() throw(Exception); MsgSvc* msgSvc() throw(castor::exception::Exception);
/** /**
* Access to the log stream * Access to the log stream
*/ */
castor::logstream& clog() throw(Exception); castor::logstream& clog() throw(castor::exception::Exception);
private: private:
/** /**
* gets the thread local storage * gets the thread local storage
*/ */
void getTLS(void** thip) throw(Exception); void getTLS(void** thip) throw(castor::exception::Exception);
}; // end of class BaseObject }; // end of class BaseObject
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* @(#)$RCSfile: BaseServer.hpp,v $ $Revision: 1.1.1.1 $ $Release$ $Date: 2004/05/12 12:13:34 $ $Author: sponcec3 $ * @(#)$RCSfile: BaseServer.hpp,v $ $Revision: 1.2 $ $Release$ $Date: 2004/05/19 16:37:15 $ $Author: sponcec3 $
* *
* *
* *
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include "castor/Exception.hpp" #include "castor/exception/Exception.hpp"
#include "castor/BaseObject.hpp" #include "castor/BaseObject.hpp"
namespace castor { namespace castor {
...@@ -114,7 +114,7 @@ namespace castor { ...@@ -114,7 +114,7 @@ namespace castor {
* @return a pointer to the message service or 0 if none * @return a pointer to the message service or 0 if none
* is available. * is available.
*/ */
std::ostream& log() throw (castor::Exception); std::ostream& log() throw (castor::exception::Exception);
/** /**
* Output stream to logfile * Output stream to logfile
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* @(#)$RCSfile: ICnvSvc.hpp,v $ $Revision: 1.1.1.1 $ $Release$ $Date: 2004/05/12 12:13:34 $ $Author: sponcec3 $ * @(#)$RCSfile: ICnvSvc.hpp,v $ $Revision: 1.2 $ $Release$ $Date: 2004/05/19 16:37:15 $ $Author: sponcec3 $
* *
* *
* *
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
// Include Files // Include Files
#include "IService.hpp" #include "IService.hpp"
#include "Exception.hpp" #include "castor/exception/Exception.hpp"
#include "ObjectSet.hpp" #include "ObjectSet.hpp"
#include "ObjectCatalog.hpp" #include "ObjectCatalog.hpp"
...@@ -81,7 +81,7 @@ namespace castor { ...@@ -81,7 +81,7 @@ namespace castor {
IObject* object, IObject* object,
ObjectSet& alreadyDone, ObjectSet& alreadyDone,
bool autocommit) bool autocommit)
throw (Exception) = 0; throw (castor::exception::Exception) = 0;
/** /**
* Updates foreign representation from a C++ Object. * Updates foreign representation from a C++ Object.
...@@ -99,7 +99,7 @@ namespace castor { ...@@ -99,7 +99,7 @@ namespace castor {
IObject* object, IObject* object,
ObjectSet& alreadyDone, ObjectSet& alreadyDone,
bool autocommit) bool autocommit)
throw (Exception) = 0; throw (castor::exception::Exception) = 0;
/** /**
* Deletes foreign representation of a C++ Object. * Deletes foreign representation of a C++ Object.
...@@ -117,7 +117,7 @@ namespace castor { ...@@ -117,7 +117,7 @@ namespace castor {
castor::IObject* object, castor::IObject* object,
castor::ObjectSet& alreadyDone, castor::ObjectSet& alreadyDone,
bool autocommit = true) bool autocommit = true)
throw (castor::Exception) = 0; throw (castor::exception::Exception) = 0;
/** /**
* create C++ object from foreign representation * create C++ object from foreign representation
...@@ -134,7 +134,7 @@ namespace castor { ...@@ -134,7 +134,7 @@ namespace castor {
*/ */
virtual IObject* createObj (IAddress* address, virtual IObject* createObj (IAddress* address,
ObjectCatalog& newlyCreated) ObjectCatalog& newlyCreated)
throw (castor::Exception) = 0; throw (castor::exception::Exception) = 0;
}; };
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* @(#)$RCSfile: IConverter.hpp,v $ $Revision: 1.1.1.1 $ $Release$ $Date: 2004/05/12 12:13:34 $ $Author: sponcec3 $ * @(#)$RCSfile: IConverter.hpp,v $ $Revision: 1.2 $ $Release$ $Date: 2004/05/19 16:37:15 $ $Author: sponcec3 $
* *
* *
* *
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <map> #include <map>
// Local Includes // Local Includes
#include "Exception.hpp" #include "castor/exception/Exception.hpp"
#include "ObjectSet.hpp" #include "ObjectSet.hpp"
#include "ObjectCatalog.hpp" #include "ObjectCatalog.hpp"
...@@ -76,7 +76,8 @@ namespace castor { ...@@ -76,7 +76,8 @@ namespace castor {
virtual void createRep(IAddress* address, virtual void createRep(IAddress* address,
IObject* object, IObject* object,
ObjectSet& alreadyDone, ObjectSet& alreadyDone,
bool autocommit) throw (Exception) = 0; bool autocommit)
throw (castor::exception::Exception) = 0;
/** /**
* Updates foreign representation from a C++ Object. * Updates foreign representation from a C++ Object.
...@@ -93,7 +94,8 @@ namespace castor { ...@@ -93,7 +94,8 @@ namespace castor {
virtual void updateRep(IAddress* address, virtual void updateRep(IAddress* address,
IObject* object, IObject* object,
ObjectSet& alreadyDone, ObjectSet& alreadyDone,
bool autocommit) throw (Exception) = 0; bool autocommit)
throw (castor::exception::Exception) = 0;
/** /**
* deletes foreign representation of a C++ Object * deletes foreign representation of a C++ Object
...@@ -110,7 +112,8 @@ namespace castor { ...@@ -110,7 +112,8 @@ namespace castor {
virtual void deleteRep(IAddress* address, virtual void deleteRep(IAddress* address,
IObject* object, IObject* object,
ObjectSet& alreadyDone, ObjectSet& alreadyDone,
bool autocommit) throw (Exception) = 0; bool autocommit)
throw (castor::exception::Exception) = 0;
/** /**
* create C++ object from foreign representation * create C++ object from foreign representation
...@@ -127,7 +130,7 @@ namespace castor { ...@@ -127,7 +130,7 @@ namespace castor {
*/ */
virtual IObject* createObj(IAddress* address, virtual IObject* createObj(IAddress* address,
ObjectCatalog& newlyCreated) ObjectCatalog& newlyCreated)
throw (castor::Exception) = 0; throw (castor::exception::Exception) = 0;
}; };
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
* @(#)$RCSfile: IRequestHandler.hpp,v $ $Revision: 1.1.1.1 $ $Release$ $Date: 2004/05/12 12:13:34 $ $Author: sponcec3 $ * @(#)$RCSfile: IRequestHandler.hpp,v $ $Revision: 1.2 $ $Release$ $Date: 2004/05/19 16:37:15 $ $Author: sponcec3 $
* *
* *
* *
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#define CASTOR_IREQUESTHANDLER_HPP 1 #define CASTOR_IREQUESTHANDLER_HPP 1
// Include Files // Include Files
#include "castor/Exception.hpp" #include "castor/exception/Exception.hpp"
namespace castor { namespace castor {
...@@ -51,13 +51,15 @@ namespace castor { ...@@ -51,13 +51,15 @@ namespace castor {
* forgotten whatever happens. * forgotten whatever happens.
* @exception Exception throws an Exception in case of error * @exception Exception throws an Exception in case of error
*/ */
virtual IAddress* nextRequestAddress() throw (Exception) = 0; virtual IAddress* nextRequestAddress()
throw (castor::exception::Exception) = 0;