#include "LDAPResult.h"
#include "LDAPException.h"
-#include "LDAPReferralException.h"
#include "LDAPUrlList.h"
#include "LDAPConnection.h"
#include <ldap.h>
#include "config.h"
#include "LDAPException.h"
-#include "LDAPReferralException.h"
#include "LDAPAsynConnection.h"
+#include "LDAPResult.h"
using namespace std;
-LDAPException::LDAPException(int res_code, const string& err_string){
+LDAPException::LDAPException(int res_code, const string& err_string) throw()
+ : std::runtime_error(err_string)
+{
m_res_code=res_code;
m_res_string=string(ldap_err2string(res_code));
m_err_string=err_string;
}
-LDAPException::LDAPException(const LDAPAsynConnection *lc){
+LDAPException::LDAPException(const LDAPAsynConnection *lc) throw()
+ : std::runtime_error("")
+{
LDAP *l = lc->getSessionHandle();
ldap_get_option(l,LDAP_OPT_RESULT_CODE,&m_res_code);
const char *res_cstring = ldap_err2string(m_res_code);
}
}
-LDAPException::~LDAPException(){
+LDAPException::~LDAPException() throw()
+{
}
-int LDAPException::getResultCode() const{
+int LDAPException::getResultCode() const throw()
+{
return m_res_code;
}
-const string& LDAPException::getResultMsg() const{
+const string& LDAPException::getResultMsg() const throw()
+{
return m_res_string;
}
-const string& LDAPException::getServerMsg() const{
+const string& LDAPException::getServerMsg() const throw()
+{
return m_err_string;
}
-ostream& operator << (ostream& s, LDAPException e){
+const char* LDAPException::what() const throw()
+{
+ return this->m_res_string.c_str();
+}
+
+ostream& operator << (ostream& s, LDAPException e) throw()
+{
s << "Error " << e.m_res_code << ": " << e.m_res_string;
if (!e.m_err_string.empty()) {
s << endl << "additional info: " << e.m_err_string ;
return s;
}
+
+LDAPReferralException::LDAPReferralException(const LDAPUrlList& urls) throw()
+ : LDAPException(LDAPResult::REFERRAL) , m_urlList(urls)
+{
+}
+
+LDAPReferralException::~LDAPReferralException() throw()
+{
+}
+
+const LDAPUrlList& LDAPReferralException::getUrls() throw()
+{
+ return m_urlList;
+}
+
#include <iostream>
#include <string>
+#include <stdexcept>
+
+#include <LDAPUrlList.h>
class LDAPAsynConnection;
* This class is only thrown as an Exception and used to signalize error
* conditions during LDAP-operations
*/
-class LDAPException{
+class LDAPException : public std::runtime_error
+{
public :
/**
* that happend (optional)
*/
LDAPException(int res_code,
- const std::string& err_string=std::string());
+ const std::string& err_string=std::string()) throw();
/**
* Constructs a LDAPException-object from the error state of a
* @param lc A LDAP-Connection for that an error has happend. The
* Constructor tries to read its error state.
*/
- LDAPException(const LDAPAsynConnection *lc);
+ LDAPException(const LDAPAsynConnection *lc) throw();
/**
* Destructor
*/
- virtual ~LDAPException();
+ virtual ~LDAPException() throw();
/**
* @return The Result code of the object
*/
- int getResultCode() const;
+ int getResultCode() const throw();
/**
* @return The error message that is corresponding to the result
* code .
*/
- const std::string& getResultMsg() const;
+ const std::string& getResultMsg() const throw();
/**
* @return The addional error message of the error (if it was set)
*/
- const std::string& getServerMsg() const;
+ const std::string& getServerMsg() const throw();
+
+
+ virtual const char* what() const throw();
/**
* This method can be used to dump the data of a LDAPResult-Object.
* It is only useful for debugging purposes at the moment
*/
- friend std::ostream& operator << (std::ostream &s, LDAPException e);
+ friend std::ostream& operator << (std::ostream &s, LDAPException e) throw();
private :
int m_res_code;
std::string m_res_string;
std::string m_err_string;
};
+
+/**
+ * This class extends LDAPException and is used to signalize Referrals
+ * there were received during synchronous LDAP-operations
+ */
+class LDAPReferralException : public LDAPException
+{
+
+ public :
+ /**
+ * Creates an object that is initialized with a list of URLs
+ */
+ LDAPReferralException(const LDAPUrlList& urls) throw();
+
+ /**
+ * Destructor
+ */
+ ~LDAPReferralException() throw();
+
+ /**
+ * @return The List of URLs of the Referral/Search Reference
+ */
+ const LDAPUrlList& getUrls() throw();
+
+ private :
+ LDAPUrlList m_urlList;
+};
+
#endif //LDAP_EXCEPTION_H
+++ /dev/null
-/*
- * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-
-
-#include <iostream>
-#include "LDAPException.h"
-#include "LDAPReferralException.h"
-#include "LDAPResult.h"
-#include "LDAPRequest.h"
-#include "LDAPUrl.h"
-
-LDAPReferralException::LDAPReferralException(const LDAPUrlList& urls) :
- LDAPException(LDAPResult::REFERRAL) , m_urlList(urls){
-}
-
-LDAPReferralException::~LDAPReferralException(){
-}
-
-const LDAPUrlList& LDAPReferralException::getUrls(){
- return m_urlList;
-}
-
+++ /dev/null
-/*
- * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-
-
-#ifndef LDAP_REFERRAL_EXCEPTION_H
-#define LDAP_REFERRAL_EXCEPTION_H
-
-#include <list>
-#include <LDAPMessage.h>
-#include <LDAPUrlList.h>
-
-class LDAPUrlList;
-
-/**
- * This class extends LDAPException and is used to signalize Referrals
- * there were received during synchronous LDAP-operations
- */
-class LDAPReferralException : public LDAPException{
-
- public :
- /**
- * Creates an object that is initialized with a list of URLs
- */
- LDAPReferralException(const LDAPUrlList& urls);
-
- /**
- * Destructor
- */
- ~LDAPReferralException();
-
- /**
- * @return The List of URLs of the Referral/Search Reference
- */
- const LDAPUrlList& getUrls();
-
- private :
- LDAPUrlList m_urlList;
-};
-
-#endif //LDAP_REFERRAL_EXCEPTION_H
#include "LDAPException.h"
#include "LDAPSearchResult.h"
#include "LDAPResult.h"
-#include "LDAPReferralException.h"
#include "LDAPSearchResults.h"
LDAPObjClass.cpp \
LDAPRebind.cpp \
LDAPRebindAuth.cpp \
- LDAPReferralException.cpp \
LDAPReferenceList.cpp \
LDAPRequest.cpp \
LDAPResult.cpp \
LDAPObjClass.h \
LDAPRebind.h \
LDAPRebindAuth.h \
- LDAPReferralException.h \
LDAPReferenceList.h \
LDAPResult.h \
LDAPSaslBindResult.h \
LDAPMessage.lo LDAPMessageQueue.lo LDAPModDNRequest.lo \
LDAPModification.lo LDAPModifyRequest.lo LDAPModList.lo \
LDAPObjClass.lo LDAPRebind.lo LDAPRebindAuth.lo \
- LDAPReferralException.lo LDAPReferenceList.lo LDAPRequest.lo \
- LDAPResult.lo LDAPSaslBindResult.lo LDAPSchema.lo \
- LDAPSearchReference.lo LDAPSearchRequest.lo \
- LDAPSearchResult.lo LDAPSearchResults.lo LDAPUrl.lo \
- LDAPUrlList.lo SaslInteraction.lo SaslInteractionHandler.lo \
- StringList.lo
+ LDAPReferenceList.lo LDAPRequest.lo LDAPResult.lo \
+ LDAPSaslBindResult.lo LDAPSchema.lo LDAPSearchReference.lo \
+ LDAPSearchRequest.lo LDAPSearchResult.lo LDAPSearchResults.lo \
+ LDAPUrl.lo LDAPUrlList.lo SaslInteraction.lo \
+ SaslInteractionHandler.lo StringList.lo
libldapcpp_la_OBJECTS = $(am_libldapcpp_la_OBJECTS)
libldapcpp_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
LDAPObjClass.cpp \
LDAPRebind.cpp \
LDAPRebindAuth.cpp \
- LDAPReferralException.cpp \
LDAPReferenceList.cpp \
LDAPRequest.cpp \
LDAPResult.cpp \
LDAPObjClass.h \
LDAPRebind.h \
LDAPRebindAuth.h \
- LDAPReferralException.h \
LDAPReferenceList.h \
LDAPResult.h \
LDAPSaslBindResult.h \
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPRebind.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPRebindAuth.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPReferenceList.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPReferralException.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPRequest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPResult.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPSaslBindResult.Plo@am__quote@